How do I create automatic discount codes from a customer's order number?

Hello,

I work for an E-commerce business that makes embroidered goods. The customer has to upload their design, and then we digitize them and have it embroidered on their apparel.

We charge a Set Up Fee to cover the cost of digitization, and if you are reusing the same design for a different order, you are refunded your Set Up Fee. However, we have no automatic process or way for our website to identify they are reusing the same design even though they are using our reorder button, so customers are still charged their Set Up Fee when ordering, and then we go in and refund them. The issues are with this is that it leaves room for human error in regards to forgetting to refund the customer their Set Up Fee, and customers write in about their Set Up Fee being included in their order.

My idea was to create automatic discounts that use the customer’s order numbers, so that way they will receive their discount on their Set Up Fee and we will be able to see what past order they are wanting to reuse the design from.

Please let me know if you guys have any recommendations on how to do this, or different methods to achieve the same goals!

Hi Hfreedm, please answer the following questions:

  • How are you charging this set up fee? Are you using an app, etc.?
  • How do customers upload their designs to your store?
  • How would you detect the customer is using the same design? Are you using cart attributes? Line item properties? Something else?

Based on the information available, I’m making the following assumptions:

  • You are using an app to allow customers to upload their designs as images (or some other file)
  • Each file has a unique ID (or hash). If you select the same design you did in a previous order, the ID will be the same.
  • The ID is stored as a cart attribute.

If so, then you’d need to do the following:

  • Create a string array metafield on customer accounts
  • When an order is placed, store the design’s ID in that array metafield
  • Create a Shopify Functions automatic discount that checks the design ID cart attribute against the value of that metafield, and then if the design has been used before, apply a discount. (Whether to make this a product or order discount completely depends on how you have implemented the setup fee)

Best,

Tobe

You could automate this process by using a Shopify app like ReCharge or Bold Custom Pricing to recognize returning customers and apply a discount for repeat designs. Another option is to create a discount code system where customers enter their previous order number at checkout to waive the Setup Fee.

For a more seamless experience, a custom app or script using Shopify Functions could check if a customer has a past order with the same uploaded design and automatically remove the fee. If you use Shopify Plus, you could create a checkout script to conditionally apply the discount based on order history.

Hi @hfreedm

Here are a few possible solutions:

  1. Use Shopify Scripts (if on Shopify Plus) – You can create a script that checks past orders and automatically applies a discount if a customer is reordering the same design.
  2. Shopify Flow + Tags (for Advanced Plan or Plus) – Use Shopify Flow to tag customers who have paid the setup fee. Then, create an automatic discount that applies when they reorder.
  3. Discount code via post-purchase email – Instead of manual refunds, send customers a unique discount code tied to their past order, which they can apply when reordering. Apps like Bulk Discount Code Generator can help automate this.
  4. Custom app or Shopify API – If you need full automation, a custom app could verify past order numbers and apply a discount automatically at checkout.
  5. Customer accounts + loyalty program – Encouraging customer accounts instead of guest checkouts can help track orders and automatically provide discounts for repeat designs.

If you’re not on Shopify Plus, Shopify Flow + tagging or discount codes via email would be the easiest workaround