Create Custom Menu in WordPress Dashboard
Complete tutorial on create custom menu in wordpress dashboard. Discover practical examples, implementation tips, and expert advice for WordPress and WooCo
Read More โAdvanced Custom Fields (ACF) offers a user-friendly interface for managing complex product data, including role-specific pricing. By setting up an ACF repeater field on your product pages, you can easily assign different values for roles like "Retailer" or "Wholesaler." This guide demonstrates how to fetch these ACF values via PHP and apply them to the product price dynamically using WooCommerce filters. It is a highly scalable solution for stores that require a clean UI for administrators while maintaining powerful pricing logic on the frontend.
Creating user role-specific pricing can greatly improve personalization in WooCommerce. This tutorial walks you through implementing custom prices based on user roles using ACF.
Step 1: Install the ACF Plugin
Install and activate the ACF plugin, which allows you to define flexible custom fields, including pricing options per user role.
Step 2: Create a Role-Based Pricing Field Group
Navigate to Custom Fields > Add New and set up a new field group. Add a Repeater Field named `custom_prices` with sub-fields: `user_role` (text/select) and `price` (number).
Step 3: Populate Custom Role Pricing
When editing a product, you can now enter different prices for each user role — such as retailer, wholesaler, or logged-in member — directly from the product editor.
Step 4: Modify the Product Price Output
Insert this code to dynamically fetch pricing according to the user role:
function set_role_based_product_price( $price, $product ) {
$user = wp_get_current_user();
$roles = $user->roles;
$pricing = get_field( 'custom_prices', $product->get_id() );
if ( $pricing ) {
foreach ( $pricing as $row ) {
if ( in_array( $row['user_role'], $roles ) ) {
return (float) $row['price'];
}
}
}
return $price;
}
add_filter( 'woocommerce_product_get_price', 'set_role_based_product_price', 10, 2 );
This ensures users see prices tailored to their roles when viewing a product.
Give Your Customers Role-Based Deals
With this setup, you can offer exclusive pricing by role — improving both conversion rates and loyalty for your WooCommerce shop. 
Search our archives or reach out to our team for solutions and expert advice.