We had an interesting case on our support line today so I thought I’d write up a tutorial for it. The customer was wanting to create a coupon for their staff members to be able to order some branded t-shirts from their company website for free.
However, they didn’t want any of the other items in the cart to be discounted as it was a fixed amount coupon that they were planning to give each staff member.
This can also be applied to other stores as well.
If you are running a campaign where you want to give a fixed discount just on a particular category it can help to do two things:
- Stop the coupon from being allowed to be applied if there is nothing from that category in the cart
- Only apply the discount to those items in the cart that belong to that category
In this way, even if they don’t use up the coupon fixed amount, it will not apply the rest of the balance to the other items.
There’s also a case as well where you might want to have the coupon automatically apply for customers when they have items from that category in their cart.
Video Tutorial: Apply A Fixed Price Coupon On A Category In WooCommerce
The video above will take you through how to set up a coupon and only have it allowed to be applied when products from a particular category are present in the cart and also when it is applied to only apply the discount to those particular products that are on that category.
Step 1 – Set the correct coupon type
The set up of the coupon type in this particular instance is very important. You need to make sure it’s set on a Fixed product discount type.
If you do not do this, it will not apply the coupon discount to only those products, it will apply to all products in the cart.
Step 2 – The two places to restrict the category (and the difference)
This isn’t really a step as such but I want to pause here for a sec to explain the differences between the two places I’m going to suggest you restrict categories.
The first one is the Usage Restrictions.
This is a section that is provided by WooCommerce core. It has a box for defining the categories that are involved.
When you have your coupon type set to Fixed product discount the coupon will give the discount only on the categories defined here.
It’s more about what the coupon is actually giving the discount to.
The second one is called Cart Conditions.
This is a section provided by Advanced Coupons for WooCommerce. It lets you define “rules” for the coupon BEFORE it is allowed to even be applied.
There is a cart condition that you can add called Product Category Exists On Cart. This makes the coupon check to see if there are any products that belong to that product category on the cart.
Step 4 – Product Categories Cart Condition
So with that all in mind, lets set up the Product Category Exists On Cart cart condition.
All you need to do is add a Condition Group, then add a Condition to the group. Select the Product Category Exists On Cart condition and then type the name of the category. It will suggest closest matches.
In this case, I typed in t-shirts and it found the category for me and then you can click on Save Cart Conditions on the tab.
Step 5 – Set The Usage Restrictions
Now we need to set up the Product Categories usage restriction. This will let the coupon know which product category should it apply itself to when giving the discount.
Simply type in the category into that box and it will find it for you.
Step 6 – Test the deal
Now you just need to test on the front of the site. It’s good practice to always test deals are working the way you intend them to when setting up coupons. This saves you from any silly mistakes.
So that is our two rules in action. You can see that the product category exists in the cart. And that the application of that discount is restricted just to that category.
I hope you found this tutorial useful and can now see how to create a coupon in WooCommerce which only applies to the product in the cart that belongs to that product category you want. Also, that it only lets the customer apply the coupon if they have a product from that category in the cart.