Generating discount/gift codes after buying specific product

New Member
1 0 0

Good morning everyone, 

I am trying to solve an issue wit my shopify store.

Among my products, I offer the opportunity to buy gifts for others, which are also personalized based on the customers' taste.

I would like it to work in a way similar to this:

- customer A wants to buy gift for B

- customer A goes to product "3 month gift" and buys it

- a discount code is automatically generated for that product, and customer A receives an email with a message (possibly a PDF) and the discount code

- A sends the email/code to B

- B goes to the store, takes the test to personalize the experience and then uses the code to get its gift for free, putting his shipping information.


I'm having a lot of issues on the "automatically generate code on order" part.

I may use a single discount code and always give them that, but it would be very risky as potentially whoever knows the code may get a product for free.

Do you have any suggestions? Thank you!

Shopify Partner
123 2 10

Hi @lucamenato, I'm Neomi from app,


We specialized in gift cards and loyalty store credit solution,

unfortunately, we don't have a solution that fits your needs, but I believe you can use gift cards to achieve a great customer experiment.


With Rise gift cards you can send the gift card directly to the recipient and schedule it for the perfect time.
this way the recipient can choose whatever he likes from your store.
You can give customer A an extra incentive to buy a gift card by giving him an extra gift card for himself using out BOGO gift card workflow

checkout our listing page and feel free to contact me at


New Member
1 0 2

Hey there @lucamenato !

Saw your post earlier today, I went ahead and built a quick solution for you on Autocode:

Shopify: Generate + E-mail Gift Discount Codes 

Using it is pretty straight forward, you can fork and deploy it right away! It takes care of the generation and creation of new Discount Codes for you when orders are placed with gifts, and the Discount Codes are automatically emailed to your customer via Gmail. All you'd need to do is just define which Gift IDs map to which Product IDs. The emails are fully customizable too.

Hopefully this helps, let me know if you have any questions!

New Member
2 0 0



This seems like it would be the solution that I need for my shopify store as well.  I have 2 product lines that need automatic email responses. 

We sell fragrances.  When a customer buys 3 samples they get a coupon for $$ off a full price purchase in the future.  I want the discount code that they receive to be different every time to prevent people sharing the codes.  Right now I have to send the discount manually, which means searching back through orders.....nightmare!  If an email could automatically be sent that gives them the unique code immediately after their purchase that would be amazing.  The sample products are all variants, and from what I can tell you cannot create tags for the variants, but I could assign them each a consistent SKU (like SAM-MS, SAM-HO, etc.) So when a customer puts three of these in their cart and checks out, an email automatically sends them a unique code that they can redeem on their next visit.

The second product is an in-store class.  I have these set up as Products and the class dates/times are variants.  When someone buys a class, I would love an automated email to go out which confirms the date, time and cancellation policy.  

I am not a coder, which is why I use shopify!  Can you let me know how to best implement any solution you can offer?  THANK YOU!!