add_action( 'woocommerce_cart_calculate_fees', 'elex_discount_price' ); 

function elex_discount_price() 


global $woocommerce; //Set the price for user role. 

$discount_price = 5; 

$set_role = array('administrator','vendor'); //Get the login user role 

$user = wp_get_current_user(); 

$user_role = $user->roles; //Check the specifc user role for discount. 

if( in_array( $user_role[0] , $set_role ) )


$woocommerce->cart->add_fee( 'Discounted Price', -$discount_price, true, 'standard' ); 


downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter