How do I send a discount code to abandoned carts that expires in 24 hours?

Hello, we are trying to accomplish the following for the Gallery 6 website. When someone abandons a cart, send them an email after 30 mins with a discount code that is valid for 24 hours.

To achieve this, we have:

  1. Created a segment for customers that have abandoned their cart in the last 1 day using this filter logic:

WHERE abandoned_checkout_date >= -1d
AND last_order_date < -1d

  1. Created a discount code with the above customer segment selected

  2. Created a recovery email containing the code that is sent after 30 mins of cart abandonment

Unfortunately, the discount code seems to continue to work even after 24 hours. It seems the customer segment logic is not working as intended.

Any guidance on fixing the logic or a possible workaround would be appreciated. Thanks!

Hi,

You can use 2 methods

  • If you are Shopify plus user then use script
  • If non Shopify plus user then use automation apps like Shopify email

Hi @Gallery6

Actutally, Shopify’s default discount codes don’t have a built-in expiration per customer. Instead, you need to generate unique, time-sensitive discount codes for each abandoned cart

You can use Shopify Flow (if on Shopify Plus) – Create a workflow that generates a single-use discount code valid for 24 hours when a cart is abandoned and includes it in the email.

Or, use an app like “Shopify Automations” or “Klaviyo” – These allow you to dynamically generate a 24-hour expiry code for each abandoned cart email.

2 Likes

Hey @Gallery6 did you find a solution for this problem already or are you still dealing with it?