How can I send unique discount codes via email after a product purchase?

I have some products (3 t-shirts) and buying one gives the user the ability to have $25/$50/$75 off specific products based on which T-shirt they purchase.

I want it to function as follows:

  • When user purchases T-shirt, they get emailed a unique code

  • One of the T-shirts has 500 stock, once it is sold out, it will not be restocked

  • So that T-shirt needs to have 500 unique codes which give $25 off specific products from a collection

  • Code would expire after one year

  • Code would have to be unique (ie to stop people giving the code to other people)

What would be the easiest way to do this?

I’ve had a look at:

  • couponcarrier

  • klaviyo

  • Selly united

  • retainful

and not had any luck

Needing them to be emailed, unique, have expiry, collection conditions, max codes, and tier pricing can mean needing to hobble together a bespoke process with different apps.

If no discounts apps are capable of this combinations of needs you may need a custom app , or a more indepth app like usemechanic to put that business logic into an automation script.

https://tasks.mechanic.dev/?q=discounts

Realistically you may just need to simplify this scheme or you can be burning a lot of time on an overcomplicated scheme. Unless you’ve done a sale like in a different medium than shopify with proven revenue generation, simplify. Or have time&budget to experiment.

If a pricing scheme is complicated to setup that’s a strong indication it could confuse customers and clog support.

Point of order: one use customer specific codes, otherwise one use and sharable

Pregenerating Discount Codes

Apps like matrixify have a process to create discounts in bulk using spreadsheets

https://matrixify.app/tutorials/import-shopify-discounts-in-bulk/

https://apps.shopify.com/search?q=bulk%20discount%20code

Brute force

A grunt way if there is only supposed to be ~500 unique codes for an equivalent item stock , create all the single-use discount-codes and put them into order notification templates with logic to dole out 1 discount per eligible order based on stock left or order-number,etc. Add some padding to that maximum for orders or you could end up in a spot where some percentage of customers at the end of the line don’t get one either from software race-conditions or orders with multiple quantities.

Shopify Plus

If your on shopify Plus use checkout scripts and Flow to tag customers

https://help.shopify.com/en/manual/shopify-plus/flow/examples#customers

https://help.shopify.com/en/manual/checkout-settings/script-editor/examples/line-item-scripts#product-discount-by-customer-tag

Alternative

This could be broken down to purchasing just gives access to a different set of products priced lower and then it’s simply inventory sync’ing and something like a soft membership management with tags. Tier pricing with or without a tier pricing app. This method ties the discount to the purchasing account and should be tested to see how it behaves in reporting.

Hi @kerchief

Renars here from Matrixify app.
Thank you for mentioning us @PaulNewton .

@PaulNewton seems to have written a great solution for this issue.

If you can generate a file with all the discount codes you need, then you sure can import that with our app.

Here we even have a tutorial specifically for importing discount codes - How to Import Shopify Discounts in bulk

I hope that our app can be useful for you here, if you need any assistance with the Matrixify app, let us know directly!