Remove cart items using Shopify Functions

Remove cart items using Shopify Functions

adkhamllama
Shopify Partner
24 0 49

Hello.
I was wondering.
Is there a way to automatically remove items from the cart using Shopify Functions?
Basically, I need to remove some items from the cart when specific condition is not met.
I was reading about Cart Transform API. But it allows to add products as much as I understood. I cannot link products that I want to remove to a specific product, but rather to the cart itself (cart total cost).
Cart and Checkout Validation API seem to show only errors when my condition does not match.

I didn't dive deep into these Shopify functions, so maybe someone can provide information.
Thank you.

Replies 6 (6)

Trending4ever
Excursionist
23 4 1

Can u go to cart and make tgat product number turn to “0” instead of “1”? That would remove the product from cart.

adkhamllama
Shopify Partner
24 0 49

Trending4ever Can items be modified from Shopify Functions API? Because I am building an app and have no access to modify cart from storefront. I don't want to use Script Tag as they are about to be deprecated soon. Therefore, I am coming to Shopify Functions, but have no idea if that possible.

Nick_Wesselman
Shopify Staff
168 42 66

This is not possible with Functions today, you might consider using a Checkout UI extension. You can also add or upvote a feature request here:
https://github.com/Shopify/function-examples/discussions/categories/feedback-cart-transform-api

Nick Wesselman | 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

cwveysey
Shopify Partner
7 0 1

@Nick_Wesselman good afternoon! I hope that this finds you as well as possible.

 

This is not possible with Functions today

 

When convenient, possible to confirm 

 

- Is this now possible via Shopify Functions? 

- If not, possible to confirm whether or not this is on the roadmap for Shopify Functions? If so, is there a public timeline that you can share? 

 

you might consider using a Checkout UI extension

 

Possible to share a visual reference of what this might look like? (any real world examples?) 

 

A condition is met and...at that point there is a visual indication that the user cannot proceed without removing an item from their cart? At that point can they e.g. click a button to remove the item? (they wouldn't need to exit checkout in order to remove the item...right?)

 

Thanks so much for your time and consideration here.

manuelpineda
Shopify Partner
9 0 5

hello, I am trying to achieve the same results. I tried doing it with functions but got no success. I will try and use webhooks to see if I can change the cart on checkouts. For example if a discount webhook is created it will trigger the update. I haven't tried it yet but I'll post the updates here.

 

garyrgilbert
Shopify Partner
414 41 170

I was thinking the same thing, apparently its still a no on that.

 

Im thinking the only way to achieve this at the moment to write javascript in the theme and monitor the cart on the front end.. I also have to dynamically update the price of a product depending on certain conditions on the cart, at least that seems to be able to be done.

 

Good luck,

Gary

- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution