I have an email with a discount code that I want to send every time a customer orders a specific product.
I’ve set up a flow (see below) which works but is inconsistent.
The flow trigger works correctly when the trigger product (the ‘Gift Card’) is shown as ordered after the ‘Voucher’ product. See below:
The purchase order is always the same in Shopify (Voucher first, Gift Card second).
But sometimes the ‘Gift Card’ is shown as ordered before the ‘Voucher’, even though it was purchased after the ‘voucher’.
When this happens, no email is sent.
Its seems like because the orders are purchased so close together, the chronological order is sometimes incorrect and I’m not sure I’ll be able to a fix this.
But I’m confused why the email isn’t triggered when the ‘Gift Card’ is shown as purchased first. It doesn’t seem like there is anything in the flow that would prevent the email from sending?
The 2nd issue is that when the flow sends the email, customers receive the same dynamic coupon code (eg {% coupon_code ‘Discount’ %} ) each time.
Is there any logic (either in the flow, or (ideally) in the email template) to count how many times the customers has purchased the trigger product or completed the flow and display the correct coupon code eg. {% coupon_code ‘Discount_1’ %} for the first order, {% coupon_code ‘Discount_2’ %} for the 2nd order etc.