Given a Coupon Promotion in a BigCommerce store and an API key for the same store, you may use the utility scripts in this repo to bulk generate coupons.
The coupons it creates are randomly generated alphanumeric strings of a length that you define. The scripts do not check for existing codes in BigCommerce prior to attempting to create them.
- Create a Coupon Promotion in your BigCommerce store
- Generate API keys for your store with the Marketing: modify scope
- Clone the repo, copy the environment variables template, install dependencies
git clone https://github.com/hatertron3000/coupon-generator
cd coupon-generator
cp .env-template .env
npm i
- Configure the following environment variables in .env:
Environment Variable | Description |
---|---|
STORE_HASH | BigCommerce store has (example: abcde12345) |
API_TOKEN | BigCommerce API token |
QUANTITY | The number of coupons to generate |
CODE_LENGTH | The desired character length of coupon codes (min: 6 max: 50) |
This repo provides two utilities: a coupon generator and a code generator.
To create coupon codes in BigCommerce:
npm run start
To generate a CSV file of codes but not push them to BigCommerce:
npm run csv
Results are stored in timestamped files saved to the ./results/
directory. If the coupon generation script is interrupted before all codes have been created in BC, the file will contain any coupon codes that were generated in BigCommerce.