There are times when doing manual work – such as creating a WooCommerce coupon – is too time consuming. Imagine you need to bulk generate 1,000 coupon codes – sure you have 2,000 minutes at your disposal to do it all by hand?
Well, today, we’ll take a look at how to bulk generate coupon codes from the WordPress backend by using a simple PHP “for“. Once the function triggers, it will just be a matter of seconds!
Enjoy!
Here’s how I bulk created 100 coupons in a few seconds with a simple snippet. If you need to generate thousands of them, make sure you don’t exceed the maximum WordPress load time – in this case I recommend running the function N times as opposed to using a $number_of_coupons greater than 1,000.
Note: in order to trigger the function, you must go to any WordPress admin URL with the “bb-gen-coupons” URL parameter e.g. /wp-admin/admin.php?bb-gen-coupons. This will make sure the coupons are generated.