Set product prices by user roles for WooCommerce with 2 easy ways

Set product price by user role in woo banner
Table of Contents

Product prices by user roles for WooCommerce is a powerful way to offer personalized pricing to different customer roles. This can be particularly useful for wholesale businesses, membership sites, or any eCommerce website where you want to provide discounts or custom pricing for specific groups of customers. 

There are two primary methods to achieve this: 

Below, we’ll explore both methods to help you implement role-based pricing in WooCommerce.

Method 1: Set product prices by user roles for WooCommerce programmatically

To set product prices programmatically, you’ll need to add custom PHP code to your WooCommerce store. 

When inserting custom code into the `functions.php` file of your WordPress theme, it’s important to take certain precautions to avoid breaking your site or causing unexpected behavior. Here are the key precautions to consider:

  1. Editing the `functions.php` file can potentially cause errors that break your site. Having a backup ensures you can restore your site to a working state if something goes wrong.
  2. If you’re adding custom code to the `functions.php` file, it’s best to do it in a child theme. This ensures that your changes won’t be overwritten when the parent theme is updated.
  3. If you have no experience in code writing or applying them to a child theme, it’s better to ask an expert or use a third-party plugin like Code Snippet.

By taking these precautions into account, you can safely follow the below steps to add custom code and minimize the risk of errors or site downtime. 

Access your theme’s functions.php file  

Go to WordPress dashboard > Appearance > Theme Editor.

Then, select the `functions.php` file of your active theme. 

Alternatively, you can use FTP or a file manager in your hosting control panel to edit the file.

Add custom code to set product prices by user roles for WooCommerce

Insert the following code snippet into the `functions.php` file. This example demonstrates how to apply 10% discounts on prices for “wholesale_customer”.

add_filter( 'WooCommerce_get_price', 'ts_custom_price', 10, 2 );
function ts_custom_price( $price, $product ) {
// Get the current user's role.
$user_role = wp_get_current_user()->roles[0];
// Set different prices for different user roles.
switch ( $user_role ) {
case 'wholesaler':
   $price = $price * 0.9; // Give wholesaler a 10% discount.
   break;
case 'customer':
   $price = $price; // Keep the regular price for customers.
   break;
default:
   $price = $price; // Keep the regular price for other user roles.
}
// Return the new price.
return $price;
}

Save Changes  

Save the `functions.php` file, and the new pricing rules will take effect immediately.

By running this code, when customers log in to the website, they will see the regular prices, 

Products regular price

However, when a user logs in as a wholesaler, they can see the discounted product price.

Products price for wholesaler using code

Notes:

  • Replace “wholesaler” with the desired user role that you have already defined in WordPress (e.g., `’customer’`, `’subscriber’`, etc.).
  • Set the value in $price = $price * 0.9 to offer the desired discount to the specified role.
  • For all other user roles not specified in the code, the product price remains unchanged.
  • This code only modifies the displayed price. It does not affect the cart or checkout calculations. To apply product prices by user roles for WooCommerce globally, you need to apply an extended code.

Method 2: Use role-based pricing for WooCommerce plugin

If you prefer a no-code solution, you can use the Role-Based Pricing for WooCommerce plugin to set product prices by user roles for WooCommerce. 

It is a powerful tool for simplifying the process of offering custom prices for specific user roles. You can define discounts or fixed prices for each role and increase or decrease prices based on your needs.

This plugin is highly customizable and let you apply advanced pricing rules on specific category or product. You can also define a date range to apply price by user role for specific product rules on your website.

Here, you can find how to use this plugin to set product prices by user roles for WooCommerce in three simple steps:

Step 1: Install and activate role-based pricing for WooCommerce plugin

As the first step, you need to download the ZIP file of role-based pricing for the WooCommerce plugin.

Then by navigating to Plugins > Add New in your WordPress dashboard, and uploading the ZIP file, you can simply install it on your website.

Open ithemeland license page

To activate the plugin, open the IThemeland tab that just appeared in your WordPress dashboard and choose a license to see the activation form.

Insert the license key in the form and click on the Activate button.

Activate role-based pricing plugin

Step 2: Add user role to WordPress

Before using the plugin, you need to create new roles in WordPress by getting help from a third-party plugin like Members.  Adding roles in WordPress using a plugin like Members is essential for fine-tuning user permissions and access control on your website. 

While WordPress comes with default users (e.g., Administrator, Editor, Author, Contributor, Subscriber), you may need to create roles to determine what those users can do. Properly managing roles ensures that users have the appropriate level of access, enhancing both functionality and security. Plugins like Members provide an intuitive way to create, edit, and assign custom roles with precise capabilities, ensuring users have the exact level of access they need. 

Step 3: Add a new rule to set product prices by user roles 

Once you have activated the plugin and added the required user roles, navigate to the plugin’s main page under WordPress dashboard > iThemeland > Role Based Pricing

Open role based pricing plugin

On the Rules page, press Add Rule to see the Rule form.

Add rule in woo role-based pricing

Now, you can set product prices by user roles for WooCommerce by following the instructions below:

  1. Add a Title like Rule 1.
  2. Mark Apply on All products item.
  3. Under the User Role Based Pricing (By user roles) section, locate the specific user role you want to assign this rule to.
  4. Then choose the Adjustment type from the list.
  5. Insert a value in the Value field based on the changes you want to make to the prices.
Set rule on all prodcuts for contributor users

Finally, press the Add Rule button to apply changes on all products in your store for specific user roles.

Saving changes of rule

Step 4: Check output to ensure the price by user role for all products is working correctly 

Let’s make an example and see how the result is displayed on the output.

Suppose that you want to show a fixed value (e.g. $100) for all product prices to customers and offer 20% discount to shop manager.

So, you need to:

  • Locate the Customer role in the user role list. 
  • Select Fixed price from the list of Adjustment Type.
  • Write 100 in the Value field.
  • Locate the Shop Manager role. 
  • Set the Adjustment type to Fixed Decrease. 
  • Insert 20 in the Value field.  
Pricing rule for customer and shop manager user roles

Save your settings by pressing the Add Rule button.

In this way, when users log in as a customer role, they can see the fixed price:

Result on customer users

However, when shop managers roles log in to your website, they can see the prices with $20 discounts.

Rule result on shop managers
Role Based Pricing for WooCommerce Banner

Other features of role-based pricing for the WooCommerce plugin

Role-based pricing for WooCommerce plugin has awesome features that allow store owners to offer personalized pricing to different user roles. This functionality is particularly useful for businesses that cater to diverse customer groups, such as wholesalers, members, or VIP customers. 

Below, we’ll explore some advanced features of role-based pricing, including category-specific pricing, product-specific pricing, variation-specific pricing, and flexible price adjustments.

Set price by user role for a specific category

With this plugin, you can set custom prices for entire product categories based on user roles. This is ideal for businesses that want to offer discounts or special pricing for specific product groups to certain user roles. For example, you can apply the above-mentioned rule to the Mobile category, only. This feature simplifies pricing management for large inventories and ensures consistent pricing across similar products.

role-base pricing on specific category

Set price by user role for the specific products

For more granular control, Role Based Pricing for WooCommerce plugin, allows you to set custom prices for individual products based on user roles. 

This is perfect for offering exclusive deals or discounts on high-demand items. For instance, you can set a lower price for a specific product for member roles or a fixed price for a premium product for wholesale buyers.

This level of customization ensures that you can tailor pricing to meet the unique needs of different customers.

To make this happen, you just need to add as many products as you need to the Select Products fields:

specific products pricing by user role

Set price by user role for specific product variation

If your store offers variable products (e.g., different sizes, colors, or styles), the price by user role can be applied to specific product variations. 

This feature allows you to set custom prices for each variation based on user roles. 

For example, you can offer a discount on a specific color variant for members or a fixed price for a particular size for wholesale customers. 

This ensures that pricing is flexible and tailored to the specific preferences of your customers.

To apply price rule on a specific variation, you need to open the variable product edit page and then open the Variations tab in the Product data section.

set role price on specific product variations

Now click on the variations you want to apply the product prices rule to see the Edit Variation form.

Scroll down this form to find the Role Based Pricing section.

Now, you can set your rule in this form as we explained before:

setting the rule for on specific variation

Flexible adjustments types

WooCommerce role-based pricing plugin also supports flexible price adjustments, giving you complete control over how prices are modified for different user roles. 

Adjustment types in role-based pricing plugin

You can choose one of the below options:

  • Fixed price: To show a new price to the specified user role.
  • Fixed Increase: To increase the current price by a fixed amount. 
  • Fixed decrease: To decrease the current price by a fixed amount.
  • Percentage decrease: To increase the current price by a percentage.
  • Percentage increase: To decrease the current price by a percentage.

For example, you can increase prices by 5% for retail customers, decrease prices by 10% for wholesale buyers, or set a fixed price of $50 for VIP members. 

This flexibility ensures that you can create pricing strategies that align with your business goals and customer expectations.

Why do you need product prices by user roles for WooCommerce?

Offering personalized product prices based on user roles is a strategic approach that can significantly benefit your WooCommerce store. This feature allows you to tailor pricing to different customer groups, enhancing customer satisfaction, driving sales, and improving loyalty. Here are some key reasons why you might need product prices by user roles for WooCommerce:

Cater to diverse customer groups

Different customer groups, such as wholesalers, retailers, members, or VIP customers, have unique pricing needs. 

By setting product prices by user roles for WooCommerce, you can offer tailored pricing that aligns with the expectations and purchasing power of each group. For example, wholesalers may require bulk discounts, while VIP customers might appreciate exclusive deals.

Boost sales and revenue

Personalized pricing encourages customers to make purchases by offering them deals that feel exclusive and relevant. For instance, offering a discount to members or specific buyers can incentivize them to complete their purchase, ultimately boosting your sales and revenue.

Improve customer loyalty

By offering product prices by user roles to loyal customers or members, you can strengthen your relationship with them. Role-based pricing makes customers feel valued, increasing the likelihood of repeat purchases and long-term loyalty.

Simplify pricing management

If you have a large inventory or cater to multiple customer groups, managing individual prices for each product can be time-consuming. Product prices by user roles allow you to set pricing rules for entire user roles, simplifying the process and ensuring consistency across your store.

Compete Effectively in the Market

In competitive markets, offering personalized pricing can give you an edge over competitors. By providing discounts or special pricing to specific user roles, you can attract more customers and stand out in a crowded marketplace.

Support wholesale and B2B sales

If your store caters to wholesale or B2B customers, role-based pricing is essential. Wholesale buyers often expect lower prices for bulk purchases, and role-based pricing allows you to meet these expectations without affecting retail prices.

Enhance marketing strategies

Role-based pricing can be integrated into your marketing campaigns to target specific customer groups. For example, you can offer limited-time discounts to subscribers or exclusive deals to members, driving engagement and conversions.

Conclusion

Implementing product prices by user roles in WooCommerce is a powerful way to meet the diverse needs of your customer base, drive sales, and enhance customer loyalty. Whether you’re running a wholesale business, a membership site, or a retail store, role-based pricing provides the flexibility and control you need to optimize your pricing strategy and stay competitive in the market.

Both methods we have provided in this tutorial offer effective ways to set product prices by user roles in WooCommerce. If you’re comfortable with coding and need full control over pricing logic, the coding approach is ideal. On the other hand, if you prefer a user-friendly and feature-rich solution, using the Role Based Pricing for WooCommerce plugin is the way to go.

Choose the method that best suits your needs and start offering personalized pricing to your customers today!