Redirect when removing items from cart - Impulse Theme

Topic summary

A user is experiencing an unwanted redirect when removing items from the cart drawer in the Impulse theme (v7.6.1). Instead of staying in the right-hand side drawer cart, the page redirects to a full cart page after product removal.

Proposed Solution:

  • Enable AJAX handling for cart updates to prevent page reloads
  • Modify the product removal event listener in theme.js or cart.js
  • Code examples provided for both jQuery and vanilla JavaScript implementations
  • Check theme settings for built-in “AJAX Cart” or “Drawer Cart” options
  • Review Shopify cart liquid files for forced redirects

Current Status:
The user has difficulty locating the correct code segment in theme.js and is awaiting more specific guidance for the Impulse theme. The discussion remains open with a follow-up request for additional support.

Summarized with AI on October 30. AI used: claude-sonnet-4-5-20250929.

Hi

When I’m removing products from my cart at the right handside from my screen, it will change screens.

You will no longer see the drawer cart at the right handside but instead you’ll be redirected to a new cart page.

Is there a way to stop the redirect?

TLDR: right hand side cart will change to last image upon removal of a product. I don’t want this, can you stop that?


/Kr

Dries

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,

Hi

Already thanks for the lengthy support, however I’m not the most competent person working with code.

I’m using the Impulse version: 7.6.1 at the moment.

I’m searching in the theme.js code, but having difficulties locating the right segment.

/kr

Dries

Hi

Did you already have time to look further into this?

/Kr

Dries