If the number of discount codes that were created or added to a batch is smaller than the number you've requested, or if you see a message saying that some codes failed to be added, here are the most likely causes:
some of the codes that were generated, imported or uploaded are already part of a discount in the store (Shopify requires that each discount in the store be unique) - if a code was previously added, it can't be added again, whether in the same or a different discount or batch
the pattern you used to generate random codes wasn't long enough to generate enough unique codes - please try using a pattern with more letters and numbers (e.g. [5LN] - 5 letters and numbers are not enough to generate 1,000,000 unique codes, the easiest solution is to increase the number to [8LN] or more)
you've reached the Shopify imposed limit of 20,000,000 codes in your store - please consider removing the discounts you are not using to make room for the new codes
Please make sure you use enough random letters and/or numbers in your code to cover the total codes you want to generate. For example, if you want to generate 1,000,000 codes using a pattern such as [2LN] will be insufficient because there are only about 900 unique codes which can be generated from that pattern.
If you're unsure what pattern to use, here are our recommendations:
Up to 100,000 codes: [8LN] (or variations such as BF-[8LN] or [8LN]-15OFF)
Up to 1,000,000 codes: [10LN] (or variations such as BF-[10LN] or [10LN]-15OFF)
Up to 20,000,000 codes: [12LN] (or variations such as BF-[12LN] or [12LN]-15OFF)