What can we help you with?

How to offer WooCommerce Category Discount?

Category discount has been one of the popular discount strategy used in WooCommerce stores. WooCommerece discount plugins are now capable of involving other WooCommerce properties like user roles, product quantity, weight, price, maximum discount amount, discount for a specific range, restrictions, and so on. Some of these discounts can be achieved by our ELEX Dynamic Pricing and Discounts Plugin for WooCommerce. We have seen how to offer discounts for different combinations of Categories with the plugin, in another blog post.

But in this article, we will take ELEX WooCommerce Catalog Mode, Wholesale & Role Based Pricing plugin and see two of the easiest ways to add discounts in WooCommerce product category.

Offering WooCommerce Category Discount

With the ELEX Catalog Mode plugin, you can offer WooCommerce discounts and markups in the following ways:

  1. Discounts/markup based on user roles applied to all product categories.
  2. Custom discounts/markup based on user roles applied to selected product categories.

1. Discounts/markup based on user roles applied to all product categories

This case can be easily achieved with the “Price Adjustment” settings of the ELEX Catalog Mode plugin. Go to Role-based Settings > Price Adjustment: (Discount/Markup) section in the plugin settings.

Let us take a use-case where we offer a 10% discount to Wholesaler in Album and Clothing category.

Below is a screenshot of three “Clothing” products. Notice the price of the products.

WooCommerce Category Discounts | Default Product Prices
Default Product Prices

In the price adjustment table, select Album and Clothing category fro Wholesaler user role, enter the percentage discount as 10 in “Price Adjustment(%)” column and enable the price adjustment setting.

The settings are as shown in the screenshot below.

WooCommerce Category Discounts | Price Adjustment settings
Price Adjustment settings in the plugin

When the above settings are applied, the updated product prices are as shown in the below screenshot.

WooCommerce Category Discounts | 10% discount for Clothing category
10% discount for Clothing category

2. Custom discounts/markup based on user roles applied to selected product categories

In the previous case, you could apply a 10% WooCommerce discount percentage on both Album & Clothing categories for Wholesalers. What if you want to offer a different discount for different categories? In our context, a different discount (or markup) for Album and Clothing.

Here’s how to do it.

Add the following code snippet to the functions.php file of your activated website theme.

add_filter('elex_catalog_discount_for_categories','elex_catalog_category_discount');
function elex_catalog_category_discount() { 
//parameters cat_id=> role,price,price(percentage),markup/discount
return array( 
        '44'=>array(
                     array('Wholesaler','','20','discount')
                   ),
        '50'=>array(
                     array('Wholesaler','','10','discount')
                   ), 
        '47'=>array(
                     array('Wholesaler','5','','markup')
                   ) 
           );
}

Where the value “44”, “50”, and “47” are category IDs for Clothing, Album, and Posters category respectively. You can see this ID in the Category URL as shown in the sample screenshot below.

WooCommerce Category Discounts | WooCommerce Category ID
WooCommerce Category ID

The array has four parameters: HTML value of the user role, amount value, percentage value, and the type of price adjustment (discount/markup).

You can get the HTML value of the user role by inspecting the WordPress user role element, as shown in the screenshot below.

WooCommerce Category Discounts | HTML value of User role
HTML value of User role

Based on the code snippet, a discount of “20%” is offered for “Clothing” category, a “10%” discount for “Album” category, and a “$5” markup for “Posters” category, only for “Wholesaler” user role.

The below screenshot shows a 20% discount on Clothing category.

WooCommerce Category Discounts | 20% Discount on Clothing products
20% Discount on Clothing products

Conclusion

This is deeper customization that does not come with the plugin, but the code snippet will work only for the ELEX WooCommerce Catalog Mode, Wholesale & Role Based Pricing plugin. You should use only either of the method, as using both of them may lead to conflict.

This solution is also possible without the code snippet (and with more customization) with our ELEX Dynamic Pricing and Discounts Plugin for WooCommerce. You can read the related blog article on this topic.

In this way, you can offer WooCommerce Category Discount. 

 


To explore more details about the plugins, go check out ELEX WooCommerce Catalog Mode, Wholesale & Role Based Pricing plugin.

Read the product setting up article to understand the plugin, in detail. Or check out the product documentation section for more related articles.

You can also check out other WooCommerce and WordPress plugins in ELEX.

Previous How to Display Stock Status in the Product Page Without Enabling the Manage Stock Option?
Next How to hide “Sale-Flash” from your WooCommerce Products? (Code Snippet)
You must be logged in to post a comment.