Email a Unique Discount Code After a Shopify Purchase

7 min setup
No coding required
Runs automatically

Reward a purchase with a one-time code the customer can only use once. When a paid order includes the product you pick, this workflow creates a unique Shopify discount code for each unit bought, sets it to expire a set number of days after the order, and emails the codes to the customer. No shared codes getting posted online, and no copying codes out of the admin by hand.

Shopify logo icon
Shopify Order Paid (Trigger)
Filter
Logic
Shopify Create Price Rule
Loop
Shopify Create Price Rule Discount Code
email icon
Email Send Email

How it works

7 steps to send every buyer their own single-use discount code, automatically

Shopify logo icon

Shopify Order Paid (Trigger)

App connector: Shopify • Time to complete: 1 minute

Runs when an order is paid, so unpaid or pending orders never get a code.

Filter

App connector: Filter • Time to complete: 1 minute

Continue only when a line item matches the product (or SKU) that earns a code.

Logic

App connector: Logic • Time to complete: 1 minute

Read that line item's quantity, and set the expiry date to the order date plus the number of days the code should stay valid (for example 30).

Shopify Create Price Rule

App connector: Shopify • Time to complete: 1 minute

Create a price rule with your discount (for example 15% off), a usage limit of 1 per code, once per customer, and the expiry date from the previous step.

Loop

App connector: Loop • Time to complete: 1 minute

Repeat once per unit bought, so buying 3 earns 3 codes.

Shopify Create Price Rule Discount Code

App connector: Shopify • Time to complete: 1 minute

Create a random, unique code under the price rule, for example with the order number and a random suffix.

email icon

Email Send Email

App connector: Email • Time to complete: 1 minute

Email the customer their code or codes, the discount, and the expiry date.

Trusted by 1,000+ merchants
Logo: Rothy's Logo: Adidas Logo: Allure Logo: GQ Logo: DraftKings Logo: Chubbies Logo: Made In Cookware Logo: MUD/WTR

Ready to send every buyer their own single-use discount code, automatically

Get setup in 7 minutes.

Use this template →

FAQs

Can each code be used only once?

Yes. The price rule sets a usage limit of 1, so each code works for one order and can't be shared around.

Can I give a code for any purchase, not just one product?

Yes. Remove the filter step and use a quantity of 1, so every paid order earns one code.

Can I send the codes by SMS instead of email?

Yes. Swap the email step for an SMS step and send to the phone number on the order.

Personalize this template

Customize this workflow even further:

Log codes to Google Sheets
Add a Google Sheets step that records each code, the order, and the expiry, so your team can look codes up.
Tag the order
Add an order tag such as discount-sent, so you can see which orders already received a code.

You're in good company

"MESA has been a game changer for us. And, if you ever get stuck, their support team is always super helpful."

  • Ico star
  • Ico star
  • Ico star
  • Ico star
  • Ico star
PetFriendly

"It's like Zapier but exactly designed for Shopify. I have been able to complete all the workflows that I've needed."

  • Ico star
  • Ico star
  • Ico star
  • Ico star
  • Ico star
Zailys

"The MESA team has been amazing at helping us set up our automations. We would highly recommend this app!"

  • Ico star
  • Ico star
  • Ico star
  • Ico star
  • Ico star
Rothy's

send every buyer their own single-use discount code, automatically

7 min setup • Fully supported if you need help