Stay on the product page after adding products to the cart - still redirecting to cart

New Member
2 0 0

Hi guys,

 

I have implemented this ATC change following the instructions on: https://help.shopify.com/en/themes/customization/products/add-to-cart/stay-on-product-page-when-item...

 

The messages load correctly, but I am still being redirected to the cart when adding items to it - here is an example page (agregar a carrito is ATC in ES ;))

 

Any help is appreciated,

 

Thanks a million,

Dmitry

 

https://greenmarkets.es/collections/higiene/products/champu-cabello-graso

0 Likes
Shopify Expert
2684 67 676

Dmitry, 

there was a version of Debut, which was adding item to cart with Ajax and then redirected visitor to cart. Do not know why they did it like this, but you can see this code in your theme.js asset, search for _addItemToCart, and pay attention to this part, which actually redirects to the cart page if adding to cart with Ajax is successful.

 .done(function() {
          window.location.href = '/cart';
        })

I'd probably recommend to upgrade to the latest version of Debut, where Ajax cart works properly.

If this is not possible, I'd add your notification code instead of the code quoted above, and remove the rest of your code.

Want to hire me to tweak a theme? Mail me at tairli@yahoo.com!
My post solved your problem? Like it!
0 Likes
Shopify Staff
Shopify Staff
189 31 24

Hello, @DmitryKuv.

 

Elias here with Shopify Support. Thank you for reaching out.

 

As @tim mentioned, there is a newer version of Debut which has this function built-in and you will be able to toggle this on or off. Updating your theme to the latest version also ensures you to have all the new features available with the Debut theme so we recommend doing it this way. Store data, such as products, collections, pages, and navigations, will be easily transferable. You will need to set up the storefront through the theme editor, you may also need to uninstall and re-install any apps that add codes to the theme. If you’re unsure whether an app needs to be re-installed, you can always reach out to the app developers through the contact information found in the Support section of the app’s page. 

 

Alternatively, you can customize the current version of Debut as @tim suggested. If you have limited knowledge with HTML, CSS, Javascript and Liquid for custom coding; our Theme Support team can explore modifying the coding for your theme as you are eligible to use the complimentary design minutes included with Shopify Basic or higher.  

 

I hope this helps. Let me know how you would like to proceed.

Elias | Social Care @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

1 Like
New Member
2 0 0

Hi Tim, thank you very much that worked brilliantly. Only issue I got now that users can't remove items from the cart on mobile anymore. Any idea, if I broke anything in the code section below, where i have replace the code?

 

 

 

.on('click', function(evt) {
evt.preventDefault();
var $el = $(this);

var imageId = $el.data('thumbnail-id');

self._switchImage(imageId);
self._setActiveThumbnail(imageId);
})
.on('keyup', self._handleImageFocus.bind(self));
},
.done(function() {
window.location.href = '/cart';
})
var self = this;

$(self.selectors.productForm, self.$container).on('submit', function(
evt
) {
evt.preventDefault();

0 Likes