Hi @Boothable ,
Yes, this issue occurs when the cart drawer is not properly handling updates via AJAX and instead forces a full-page reload upon item removal.
Here’s how to fix it:
Enable AJAX for Cart Updates:
Open your theme’s JavaScript file (usually in theme.js or cart.js).
Ensure that product removal is handled via AJAX instead of a page reload.
Modify the Product Removal Event:
Look for an event listener on the “Remove” button.
If the event triggers a window.location.href change to /cart, modify it to update the drawer without redirection.
Example Code Fix:
$(document).on('click', '.cart__remove', function(event) {
event.preventDefault();
var removeURL = $(this).attr('href');
$.ajax({
type: 'POST',
url: removeURL,
success: function(response) {
// Update cart drawer without redirecting
$('.cart-drawer').html($(response).find('.cart-drawer').html());
}
});
});
If using Vanilla Javascript:
document.querySelectorAll('.cart__remove').forEach(button => {
button.addEventListener('click', function(event) {
event.preventDefault();
fetch(this.href, { method: 'POST' })
.then(response => response.text())
.then(html => {
document.querySelector('.cart-drawer').innerHTML =
new DOMParser().parseFromString(html, 'text/html')
.querySelector('.cart-drawer').innerHTML;
});
});
});
Check Your Theme Settings:
Some themes have a built-in setting to enable “AJAX Cart” or “Drawer Cart.” Look in Online Store → Themes → Customize → Cart Settings.
Check Shopify Cart Liquid Files:
If the theme forces a redirect in cart.liquid or cart-template.liquid, disable it.
If you’re using a third-party Shopify theme, it might have its own script handling the cart.
Let me know what theme you’re using, and I can give you more specific guidance!
Regards,