0

I want to redirect the client to the shopping bag page when they success add the product. I am using demandware of the website.

<button id="add-to-cart" type="submit" title="Add to Bag" value="Add to Bag" class="button-fancy-large add-to-cart halfactive"><span class="bag-icon">Add to Bag</span></button>
sum man
  • 73
  • 1
  • 1
  • 5

4 Answers4

0

I assume you mean in Demandware since you tagged it as such. Basically your add to cart button should be posting to a pipeline or a continue interaction node, after you do the actually adding to the cart you can do a jump node to cart-show.

Ryan Rife
  • 169
  • 2
  • 14
0

You would need to write an ajax call on click of the add button. That would do the following steps.

  1. Ajax call that will inturn call the pipeline that adds the product to the cart
  2. Add a successhandler fuction
  3. In the success function, write a JS redirect code using location syntax
Anup Mali
  • 41
  • 1
0

Try to code something as below

var addItemToCart = function (form, addToCartButton) {

var $form = $(form),
    $qty = $form.find('input[name="Quantity"]');
if ($qty.length === 0 || isNaN($qty.val()) || parseInt($qty.val(), 10) === 0) {
    $qty.val('1');
}
var data = $form.serialize();
var bundleDataCtr = '';
data += '&' + User.CSRFTokenName + '=' + User.CSRFTokenValue;
if (addToCartButton !== null && addToCartButton !== '') {
    bundleDataCtr = addToCartButton.closest('.bundle-data-container');
    if (bundleDataCtr.attr('data-bundle-child-pids') !== undefined) {
        data += '&' + 'childPids' + '=' + bundleDataCtr.attr('data-bundle-child-pids');
    }
}
return TPromise.resolve($.ajax({
    type: 'POST',
    url: util.ajaxUrl(Urls.addProduct),
    data: data
}));

};

Community
  • 1
  • 1
RIZWAN
  • 1
  • 1
0

Still assuming this is about demandware, this is an example of an "add to cart" url on that platform.

URL follows a pattern for any demandware site, so you will need to replace the brand-specific portions of the URL.

The "PID" or SKU will of course be subject to going out of stock as well, so you will want a mechanism for ensuring that your links point to valid PIDs.

Example for hats on Burton Snowboard website: https://www.burton.com/on/demandware.store/Sites-Burton_NA-Site/en_US/Cart-AddProduct?pid=F18-111231045001SZ

Example for MGEMI shoes: http://mgemi.com/on/demandware.store/Sites-mgemi-Site/default/Cart-AddProduct?pid=889235286843

Example for Lancome beauty products: https://www.lancome-usa.com/on/demandware.store/Sites-lancome-us-Site/default/Cart-AddProduct?pid=3614271682369