Remove Line Item From Cart (Liquid or Cart API)

New Member
1 0 0

Hey guys,

I'm currently working in a expiration date feature for my cart, in this case I'm adding an expiration timestamp to my product properties before adding it to cart with Cart API.

The idea is to check in cart (Liquid time of JS time) if the timestamp already surpassed it's 7 days lifespan, if it did I would need to remove that line item from cart.

I dont see docs from liquid that could allow me to do this but I know that I might be able with js like this while using the update from Cart API.

var formData = 'updates[' + variantID + ']=0';

Any additional ideas that I could add here? Is there a way to do this with Liquid?

Thank you in advance!
136 29 51

Liquid cannot manipulate the cart, or anything for that matter, only output data based on what is there. You would be looking at JS for this, probably a page load event that iterates through the cart items and checks this. I don't think cart items have a time stamp by default, so you might need to modify your add to cart function to add the timestamp as line item property.

Developer of Liquify Chrome Extension -- Enhance the Shopify Theme Code Editor

Theme Developer -- Drop me a line