How to automatically remove expired products from cart?

Hi everyone.

I’m not a developer, I don’t have a massive understanding of coding, so please be patient with me :slightly_smiling_face:

I’m trying to customise something in my shop (dawn theme).

I am creating some limited time listings with a countdown timer in the product page.

When the timer hits 0, the add to cart button in the product page disappears, and the item can’t be bought anymore.

I have created a metafield and linked it to the product, so I can set the end time of the listing.

The problem is that the product can still be bought if it’s been added to the cart before the end of the listing, as it stays there up to 10 days.

I tried to play with the code in order to automatically delete the item in the cart when the listing has ended, but with no success. I’ve spent the last 2 days trying, and I’ve run out of ideas on how to do this.

Has anyone got any clue how I could achieve this?

Thank you,

Andrea

1 Like

@cinc0

Thank you for reaching out and posting this question!
Sorry you are facing this issue, it would be my pleasure to help you.

Welcome to the Shopify community! :blush:
Thanks for your good question.

Please share your site URL,
I will check out the issue and provide you a solution here.

Hi,

Thank you for your message.

Sure, the URL of my site is 23a08f.myshopify.com.

It’s basically an empty site, I started working on it last week and I was trying to add all the features I need before committing to it.

Thanks,

Andrea

Was an answer or solution provided for this issue?