User roles are already build into WordPress and many plugins can take advantage of this. The User Role Editor plugin for example is a great plugin to manage user roles. Assigning roles can be done from the user page. In this post I’m going through setting up user role based discounts with the Advanced Pricing for WooCommerce plugin.

For this scenario I’m going to set a scenario where you’d want to have 2 different ‘tiers’ of discount for customers, and a 20% discount for your employees.

To get started you’ll need to have the Advanced Pricing plugin purchased and installed, along with the aforementioned User Role Editor plugin (or any other user role management plugin / custom code).

Setting up User Roles

To create a new user role head over to the Users > User Role Editor page and click the ‘Add role’ button on the right side of the screen. A popup will appear where you can enter the user role name and if wanted duplicate it from an existing role. For the employees and tier levels its most fitting to duplicate the ‘Customer’ role.

Depending on if you need your employees to have more rights / management capabilities you can also choose to duplicate this from the ‘Shop manager’ role.

When the roles are created you can go find the user on the Users > All Users page and assign the user role.

Creating a Advanced Pricing Rule

From the WooCommerce > Settings > Pricing section you can create a new pricing rule;

From this next screen you’ll see two sections. The first section determines if pricing rule should apply based on the conditions you set. In the second area you can configure the pricing action; whether this is a discount or addition that should be applied as the regular shown product price or as a sale price.

Setting Role Based Pricing Conditions

The first step is to configure the conditions correctly. Using the ‘User role’ condition you can assign this pricing rule to only a specific user role. If you want to apply this same rule to multiple user roles make sure to use the ‘Add OR group’ button. This adds a ‘OR’ condition group instead of a user being required to have multiple user roles assigned when using the ‘+’ button.

With the above setup the logic is: “If the visitor has a user role of ’employee’ OR has a role of ‘tier-2′”.

In addition to the User role based conditions it is possible to target a specific sub-group of products, for example from a certain category, to only apply the pricing action. Right now its only based on a User role condition, so it applies to all products.

Setting the Pricing Action

Next up is configuring the pricing action. This pricing action will be applied to the products when the conditions match. In this case I’d want a 20% discount for both the tier-2 customers and the employees. I choose the ‘Sale price’ for the pricing type so it shows the regular price with a strikethrough on the product page.

Make sure the Advanced Pricing rule is enabled and you’ll be all set. Replicate the same type of setup for any other discount rules you’d like to use.

Happy selling!

About the author: Jeroen Sormani is actively building WordPress, WooCommerce and Easy Digital Downloads plugins. Slightly obsessed by writing high quality code.
Follow Jeroen on Twitter

Leave a Reply

Your email address will not be published. Required fields are marked *