Bulk discount creation

Bulk discount creation

HumanDactyl
Shopify Partner
1 0 0

We'd like to create a 15% off coupon with a one-time-use unique code that gets printed on an insert in the package.  I need to generate about 3000 of them today.

 

Customers should be able to use each code one time and get another one in the next order to use.

 

In the current non-deprecated API, I see two options:

* Call discountCodeBasicCreate 3000 times with proper parameters.  If this is correct, how fast/slow can I go to avoid rate limiting?

* Call discountCodeBasicCreate once then call discountRedeemCodeBulkAdd 100 at a time.  I don't understand how this API works behind the scenes.  Does the code get converted to the code in discountCodeBasicCreate?  How do I let users only use their code once but get another code in the next order?  How do I hide the code in discountCodeBasicCreate from being used?

 

Thanks for the help.

 

Reply 1 (1)

ShopifyDevSup
Shopify Staff
1453 238 501

Hey @HumanDactyl

 

The first option is possible, however based on your use case, the second mutation would be best. 

 

As for how fast you can go, you can see the rate limiting here: https://shopify.dev/docs/api/usage/rate-limits#compare-rate-limits-by-api 

 

Using discountRedeemCodeBulkAdd, the addition of the 100 codes is done async, so you'll be able to go a lot faster only making 30 requests instead of 3000. 

 

Let me unpack that a little bit for you to show what's happening behind the scenes. 

 

First, the discountCodeBasicCreate is where you'll set up all of your discount rules. 

 

Here's a screenshot of what that will look like in the admin: 

 

From there, next you'll call the discountRedeemCodeBulkAdd mutation with a list of the first 100 codes. These codes will be added along with the initial discount you've created and will have all of the same rules. 

 

Here's an example of what that looks like in the admin after it's complete: 

 

This helps keep all of the codes from your package insert in a single place. Easier to manage if you need to change any of the discount rules, and better for tracking your campaigns. 

 

Hope that helps, 

 

- Kyle G.


 

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog