Set WooCommerce Prices by User Role with ACF
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.