Stay on Product Page after adding products to cart - Debut

New Member
2 0 0

I have followed the instruction in this tutorial to stay on the product page after adding a product to cart.

https://help.shopify.com/en/themes/customization/products/add-to-cart/stay-on-product-page-when-item...

I can see the added content briefly but am still being directed to the cart page?

0 Likes
New Member
2 0 0

Were you able to fix this, because I've got the same problem...

0 Likes
Highlighted
Shopify Partner
1657 278 347

Hi @MichelleGee  and @sarabear84 

try this code:

Add this code in your asset->theme.js file at bottom of file.

  $(document).on('click', '[name="add"]', function(e) {
   e.preventDefault();
    $.ajax({
      type: 'POST',
      url: '/cart/add.js',
      data: $('[action="/cart/add"]').serialize(),
      dataType: 'json',
      success: function(cart_item) {
         alert('Product added');
      } 
    })
  });

Note: If you want to make further changes then you have to add your code with this js

Want to modify or custom changes on store hire me.
If helpful then please Like and Accept Solution.
Email: jasoliyabrijesh123@gmail.com
Skype: jasoliya.brijesh
0 Likes