Generate One-Time Coupons in Bulk for WooCommerce (Free or Paid)

Creating bulk one-time coupons in WooCommerce can save hours of manual work when running promotional campaigns. Whether you need to generate unique codes for a flash sale or distribute personalized discounts to your email list, there are 2 reliable methods to achieve this: using a lightweight plugin or implementing custom code. 

We’ll walk through both approaches step by step. Plus, we’ll explore how automatic discounts can offer even better control over your promotions – without requiring coupon codes at all. 

How to bulk-generate unique WooCommerce coupon codes 

You can generate unique WooCommerce coupon codes in bulk using 2 methods. The first uses a free plugin that handles everything through your WordPress dashboard. The second uses custom code for more advanced control. Both approaches create one-time-use coupons quickly and efficiently.

Bulk-generating coupons with Coupon Generator for WooCommerce

Coupon Generator for WooCommerce plugin download page

Here’s how to create bulk coupons using the free Coupon Generator plugin:

  1. Go to PluginsAdd New in your WordPress dashboard. Search for “Coupon Generator for WooCommerce” and click Install Now, then Activate.Searching and installing the Coupon Generator for WooCommerce plugin
  2. Navigate to MarketingCoupon Generator to begin the process.First step in the generation process for WooCommerce Coupon Generator
  3.  Adjust the general coupon settings, such as the discount type, coupon amount, free shipping, and expiry date.Determining the discount type, amount, and coupon expiration date
  4. If relevant, apply your usage restrictions. In this example, we’ll make the coupon applicable only to carts equal to or more than $100 with a maximum of $500 spent. We’ll also make sure it doesn’t combine with other coupons and excludes items that are already on sale.Configuring the usage restrictions for coupons
  5. You can also impose usage limits, such as how many times a customer can use this coupon or the number of items in the cart.Applying usage limits to coupons
  6. Choose the number of coupons you want to generate.Choosing the number of coupons to generate
  7. Generate your coupons.Generate coupons
  8.  If you want, you can also download them as a .txt file.Generated coupons as a .txt file
  9.  To manage your coupons in WordPress, just navigate to Marketing Coupons.Coupons view in WooCommerce
  10.  Your coupons are ready to use! 

Using code snippets for custom bulk coupon creation

1. Create a script for generating the coupons. Paste the code below into a file called generate_coupons.php:

<code><?php
// Include WordPress and WooCommerce core
require_once('wp-load.php'); // Adjust path if this file is in a subfolder

if ( ! current_user_can( 'manage_woocommerce' ) ) {
die( 'You do not have permission to access this script.' );
}

// Number of coupons to generate
$number_of_coupons = 100;

// Coupon settings
$discount_type = 'percent'; // Options: 'fixed_cart', 'percent', 'fixed_product'
$discount_amount = 20; // Discount amount
$expiry_date = date('Y-m-d', strtotime('+30 days')); // Expiry date 30 days from now

// Generate coupons
for ( $i = 0; $i < $number_of_coupons; $i++ ) {
$coupon_code = 'COUPON_' . wp_generate_password(8, false); // Unique coupon code
$coupon = array(
    'post_title'   => $coupon_code,
    'post_content' => '',
    'post_status'  => 'publish',
    'post_author'  => 1,
    'post_type' => 'shop_coupon',
);

$new_coupon_id = wp_insert_post( $coupon );

// Add meta data to the coupon
update_post_meta( $new_coupon_id, 'discount_type', $discount_type );
update_post_meta( $new_coupon_id, 'coupon_amount', $discount_amount );
update_post_meta( $new_coupon_id, 'individual_use', 'yes' );
update_post_meta( $new_coupon_id, 'usage_limit', '1' );
update_post_meta( $new_coupon_id, 'expiry_date', $expiry_date );
}

echo "$number_of_coupons coupons generated successfully!";
?></code>Code language: PHP (php)

2. Use SFTP to upload this file into the root folder of your WordPress installation. Name the file generate_coupons.php.

3. Go to yourwebsite.com/generate_coupons.php to run the script. You should see a blank page with the text “100 coupons generated successfully!”.

4. From your dashboard, go to Marketing Coupons, where you should see 100 new coupons as shown below:

Results of generating coupons with a code

There’s a better way…

Danger! generating coupon codes in bulk is not a performant way!

Generating coupon codes in bulk isn’t a performant way to offer discounts. Each coupon code fills up the database with a lot of extra information, so they can slow your site down if used too much.

Instead, consider using automatic discounts that are applied to products (or the cart) without needing coupon codes at all.

Why automatic discounts offer better promotional control

Running promotions with traditional coupon codes creates several challenges for e-commerce stores. Managing individual codes, tracking their usage, and preventing misuse can become a full-time job. Automatic discounts solve these problems while offering much better control over your promotional strategy, plus a better customer experience.

  • With automated rules, you gain instant flexibility to modify your promotions. Need to adjust discount amounts across hundreds of products? A few clicks will update everything simultaneously. Want to stop a promotion when stock runs low? The system handles it automatically. This real-time control helps protect your profit margins and inventory levels.
  • Automatic discounts also eliminate common coupon problems. No more shared codes appearing on coupon sites, no expired codes frustrating customers, and no manual verification of eligibility. The system applies discounts only when customers meet your specific criteria, whether that’s cart value, product combinations, or customer status.
  • Finally, the data insights from automatic discounts prove invaluable. You can track exactly how discounts influence purchasing behavior, which product combinations work best, and how different customer segments respond. This information helps refine your promotional strategy over time.

WooCommerce Discounts: Automated alternatives to one-time codes

WooCommerce Discounts by Studio Wombat homepage

WooCommerce Discounts gives store owners sophisticated tools to automate their promotional strategies without relying on traditional coupon codes. The plugin’s approach to discounting focuses on creating rules that automatically apply when customers meet specific conditions or choose certain products. 

You can choose between multiple types of discounts, including: 

All discounts can be scheduled for a particular period, allowing you to set up promotions months in advance and decreasing your workload around busy periods. 

Setting up these sales is easy! 

  1. Once you install the plugin, go to Marketing → Discounts, and choose the type of discount you want to create. Let’s go for a flat discount.Choosing a flat discount
  2. Then, name your sale and adjust the period if needed.Naming and scheduling a flat discount
  3. Choose between a percentage or fixed discount and then write the amount. Here is also where you decide whether you want to apply this storewide or to a specific batch of products only – categories, variations, tags, etc.Adjusting the discount settings: Products and amount
  4. If you want, you can include a message that will show up on the eligible products or the customer’s cart.Discount content settings for product pages and carts
  5. Add any extra conditions, such as user roles or minimum cart amount, save your settings, and you’re done! Flat discount extra conditions and summary

The plugin automatically handles complex calculations and applies discounts at checkout, ensuring accuracy and consistency. This eliminates the friction of coupon codes while maintaining full control over your promotional strategy. Store owners can focus on creating effective promotions rather than managing coupon distribution and usage.

Upgrade your store’s promotional strategy today

While WooCommerce offers multiple ways to generate bulk coupons, automatic discounts through a plugin like WooCommerce Discounts provide better control and efficiency. You can create either one-time coupon codes using the free plugin or the custom code solution outlined above. Still, it’s much more efficient to implement automated discounts that work silently in the background.

For most stores, switching to automatic discounts saves time, reduces errors, and creates a smoother customer experience. With features like role-based pricing, bulk discounts, and BOGO deals, you can build sophisticated promotional strategies that drive sales without the hassle of managing coupon codes. Ready to transform your store’s promotions? Download WooCommerce Discounts and start automating your discount strategy today.

Share