website url https://budget4gadget.com/ . I want to add a “remove” button to the cart, how can I do that? Thanks.
Topic summary
Goal: Add a “remove” button to the Motion theme that removes items directly from the cart drawer (slide-out mini-cart) without redirecting to the cart page.
What was tried:
- A community member shared code: add a remove link in cart-item.liquid and use jQuery to POST /cart/update.js with updates[variant_id] = 0, then remove the item’s DOM node on success.
- The script uses event delegation with e.preventDefault() and targets .cart__remove a, relying on a data-id (variant_id) attribute.
Issue encountered:
- Despite the AJAX approach, clicking the remove link still redirects to the cart page instead of updating the cart drawer in place.
Further attempt:
- Suggested adding a data-id attribute in cart-item.liquid (screenshot provided), but it did not resolve the redirection behavior.
Current status and next steps:
- No working drawer-specific solution confirmed in-thread; the issue remains open.
- Shopify staff recommended consulting the Motion theme documentation and contacting the theme developer for theme-specific guidance. An image attachment (screenshot) was referenced for markup context.
I am using Motion Theme
Hii @Nemanja2 ,
Can please add below code in cart-item.liquid
And add below js in custom.js
jQuery(document).on("click", '.cart__remove a', function(e) {
e.preventDefault();
var variant_id = jQuery(this).attr('data-id');
// console.log(variant_id);
var obj = {};
obj[variant_id]= 0;
removem_data = { updates: obj };
jQuery.ajax({
url: "/cart/update.js",
type: "POST",
data: JSON.stringify(removem_data),
contentType: "application/json",
dataType: 'json',
success: function(responce) {
$('.cart__item[data-id="'+variant_id+'"]').remove();
}
});
});
@Rajvi_patel_1 The code works, but I would like it not to take me to the cart page, but to remove the product from the cart drawer. Is that possible?
@Nemanja2
Please add data-id in cart-item.liquid like this
@Rajvi_patel_1 it didn’t work, it still takes me to the cart page. Do you know any other solution?
Hey, @Nemanja2
Eunice here from Shopify. Thanks for posting!
To find support for this particular question I recommend checking out the theme’s documentation. Alternatively, you can contact the theme developer for support.
It’s good to note that the Shopify Community is still a great place to get support for your third-party theme, as other members might have the same theme as you!
Nice store by the way. Have you thought about adding your social media links to your footer? Social proof is one of the most effective levers an e-commerce business has for building trust, and it has the potential to become even more powerful as you grow. Check out this Shopify blog to learn more.
