It is to my understanding that first I have to create a price rule before actually creating the discount code. My question is if I want to create 20 unique code for 20 customer, do i have to create 20 price rule then create a discount code with each of the price rule or i can create 1 price rule and create 20 discount code with that price rule
Note that I am aware of the discount code creation job but it is still in Beta (https://help.shopify.com/api/reference/discountcode#batch_create)
I have also see a few topic on this one but that was 6 months ago and I don't know if the answer is still the same
As long as the discount codes will have the same discounting criteria (discount amount, products discounted, etc.) you can create more than one discount code per price rule now.
While it is still in beta, I would wholeheartedly recommend giving the batch discount code job a try that you had linked to - it's pretty fantastic if I dare say so myself. You can create the discount codes one at a time if you want to as well, though.
If you do happen to run into any issues with the batch process, feel free to provide your feedback here!
Actually the docs say everywhere that:
It is recommended to use the same value for code as the associated price rule title since only the title is searchable in the Shopify admin. For example: price_rule.title = ABC123 and discount_code.code = ABC123
So from the doc, I guess that it's better to keep a 1-1 relationship between discounts and price rules.
That is leftover in our docs from when price rules and discount codes were always a 1-1 relationship, and a price rule couldn't support more than one discount code.
When batch creating multiple codes, the codes won't have the same value so that comment isn't as relevant anymore - but batch creation is also still in beta. I'm sure that once it is fully rolled out, you'll see that documentation changed accordingly.
The documentation still states to this day to "Use the same value for code as the title property of the associated price rule.".
Have the docs still not been updated for a reason?