הנחה קבועה לפי תפקיד בתעריף קבוע

PHOTO EMBED

Tue May 18 2021 20:11:58 GMT+0000 (Coordinated Universal Time)

Saved by @Shesek

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' ); 

} 

}
content_copyCOPY