Black Friday & Cyber Monday SUPER SALE ALL WEEK:
Grab 40% OFF on plugins
Days
Hours
Minutes
Seconds

Understanding WooCommerce Coupon Code Restrictions

Coupon Codes are a way of providing customers with an incentive to buy, which benefits both the customers and the business. Customers get the products they want for a lower price, and the eCommerce store generates revenue.

While giving excessive usage control over the coupon can be beneficial for the customers, the same may not be the case for the business. There is a high chance of misusing the coupon code, which will lead to a loss for the store. So the store owner should have control over the usage of the coupon code.

As an eCommerce solution, WooCommerce also provides an option for adding coupon codes with some basic usage restrictions like minimum spent while purchasing or coupon codes can be added for certain products or categories, etc. And some of the restrictions which are necessary for a store but are not available in default WooCommerce can be added using available extensions or it can be added programmatically using code snippets.

In this post, we will discuss some of the basic restrictions required for an eCommerce store. It will be divided into two sections which will explain the Default usage restrictions available in WooCommerce and another one with the usage restrictions which are required but can be used only with the extensions or added programmatically.

Default Usage Restrictions in WooCommerce

Some of the WooCommerce default usage restrictions are:

1. Order Total

Order total restriction will be useful to set a minimum spend on the items purchased for taking the benefit of a coupon code. Like, the customer can only use the coupon code if the items purchased are worth $100 or more.

This can be highly used for the coupon codes which are displayed publicly on the website or any marketing platform. An example of such coupon code would be the discount offers given on any festivals or it could be discounts on the new purchases from any social media platforms like Google Ads.

2. Individual Use

Allowing multiple coupon usage on a single cart is not the right option for the business. It can lead to a heavy loss in revenue. This restriction will help a store owner to create a coupon code which when used, other coupon codes cannot be used in conjunction with it.

3. Exclude Items on Sale

Items on sale are already available at a discounted price, so some store owners may not want to give any additional discount through coupon codes for the purchase of such items. This restriction will help them to disable the usage of coupon codes on items on sale.

4. Products

This restriction can be helpful to add coupon codes for a certain range of products or to exclude a certain range of products from the applicability of the coupon code. The products can also be divided into categories and the coupon codes can be created for each category. For example, an eCommerce store selling multiple products like Electronics, Fashion, Computers, etc, they may not want to provide discounts for all of the categories. So they can create coupon code for certain categories like Fashion and send them to their customers.

5. Email Address

Restricting coupon codes using email id will be useful in situations where you want to provide discounts to only Gmail accounts if the customer is purchasing the products from the Google Ads given. Or when you are providing a coupon code to only a single customer, so you can restrict it with the email id of that customer to avoid any misuse.

WooCommerce provides a quick guide on Coupon Management which explains the coupon creation and the options available for the coupon. You can take a look at the guide and create coupons based on your usage.

Coupon Code Usage Restriction
Coupon Code Usage Restriction

Usage Restrictions with WooCommerce Extensions

Some usage restrictions available using the WooCommerce Extensions are:

1. Specific Customers

This can be divided into two options, one for new customers and another for existing customers.

New customers coupon restriction can be useful to provide a discount on the first sale which can help bring in more and more new customers, without sacrificing margins for those who have already purchased.

Existing customer coupon restrictions can be useful in the below scenarios:

  1. You want to reward your existing customer with a special coupon for being your long time customer.
  2. If they have not purchased something from your site for long and you want to attract them for further purchases, provide them some exciting discounts.
  3. If you have added any new collection to your website and you want your existing customers to purchase them at a lower price, then this option can be useful.

Extensions: WooCommerce Coupon Restrictions

2. Location

This option can be useful to restrict coupons for certain areas like country, state, zip code/postcodes. For example, some coupons are occasionally available for certain countries like Diwali for India, Black Friday for the United States, etc.

Extensions: Smart Coupons, WooCommerce Coupon Restrictions

3. User Roles

User role restriction can be helpful for providing coupon code usage to only certain types of customers. This would be helpful if you have a membership-based store, then coupons can be created for different members, or for the user role like Premium Customer, Retailer, Wholesaler, etc.

Extensions: Smart Coupons, WooCommerce Coupon Restrictions, WooCommerce Extended Coupon Features PRO

4. Payment Method

Certain coupons are only available for the customers when they select a particular payment method on checkout. For example, a discount of an additional 5% will be given when a customer makes a payment using a specific credit/debit card at checkout. This restriction will help to set up coupon codes for payment methods.

Extensions: Smart Coupons, WooCommerce Extended Coupon Features PRO

We also have an extension Payment Gateway Based Fees and Discounts for WooCommerce which does not add any usage restrictions to the coupons but it lets you add fees and discounts based on the payment gateway selected by the user at the checkout.

5. Shipping Method

The same way as payment methods some coupons are only available for the customers when they select a particular shipping method on checkout. For example, a discount of an additional 5% will be given when a customer will pick up the products from the store and does not want them to deliver. That will be while selecting the Local Pickup shipping method.

Extensions: Smart Coupons, WooCommerce Extended Coupon Features PRO

Adding Usage Restrictions using Code Snippets

You don’t have your required restriction mentioned in the above list? No problem, WooCommerce also has an option to add the coupon code restriction via a hook.

Apart from the above restrictions, there is one more restriction that could be required by the store owners, i.e. Adding coupons based on the order quantity. This will be used to restrict the coupon code only for the customers who purchase a minimum amount of quantity set. For example, a customer purchase more than a certain quantity, say 50 or more, then give them a 20% discount. This can be more useful for the business who deals in both retail and wholesale.

Add the below code to the functions.php file of the child theme or using any code snippets plugin for adding a Minimum Order Quantity field on the Usage Restriction tab.

/**
 * Add new field in usage restriction tab for WooCommerce coupons
 */ 
function ts_woocommerce_coupon_options_usage_restriction( $coupon_get_id, $coupon ) {
    woocommerce_wp_text_input( array( 
        'id' => 'order_quantity',  
        'label' => __( 'Minimum Order Quantity', 'woocommerce' ),  
        'placeholder' => __( 'No minimum', 'woocommerce' ),  
        'description' => __( 'This field allows you to set the minimum quantity allowed to use the coupon.', 'woocommerce' ),  
        'desc_tip' => true,  
        'type' => 'text',  
    )); 
}
add_action( 'woocommerce_coupon_options_usage_restriction', 'ts_woocommerce_coupon_options_usage_restriction', 10, 2 );
Minimum Order Quantity restriction
Minimum Order Quantity restriction

To save the value of this option use the below code snippet.

/**
 * Save the usage restriction option 
 */
function ts_woocommerce_coupon_options_save( $post_id, $coupon ) {
    update_post_meta( $post_id, 'order_quantity', $_POST['order_quantity'] );
}
add_action( 'woocommerce_coupon_options_save', 'ts_woocommerce_coupon_options_save', 10, 2 );

Once the restriction is added, to validate it on the WooCommerce Cart, you need to use the below code snippet.

**
 * Check if the coupon code is valid while applied to the cart.
 */
function ts_woocommerce_coupon_validation( $is_valid, $coupon ) {

    /**
     * Selected coupons allowed only for mentioned order quantity
     */
  $total_quantity = WC()->cart->get_cart_contents_count();
    if ( isset( $total_quantity ) ) {
        if ( $total_quantity < get_post_meta( $coupon->get_id(), 'order_quantity', true ) ) {
            $is_valid = false;
        }
  }
  
    return $is_valid;
}
add_filter( 'woocommerce_coupon_is_valid', 'ts_woocommerce_coupon_validation', 100, 2 );
Coupon code not valid as quantity is 1
Coupon code not valid as quantity is 1

For certain usage restrictions, like providing coupon code to the customers paying using Credit/Debit Card, or if a customer purchases a minimum set quantity, etc. you may want to apply the coupon code automatically to the cart. You can go through our earlier post which explains how to apply coupon code automatically to the WooCommerce cart.

Browse more in: WooCommerce Guide, WooCommerce, WooCommerce Tutorials

Share It:

Subscribe
Notify of
0 Comments
Newest
Oldest
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x