הנחה קבועה לפי תפקיד באחוזים
Tue May 18 2021 20:12:39 GMT+0000 (Coordinated Universal Time)
Saved by
@Shesek
function sv_discount_price_percentage($cart) {
global $woocommerce; //Set the price for user role.
$discount_percentage = 0.1;
//כל 0.1 שווה ל10 אחוז
$set_role = array('administrator', 'vendor'); //Get the login user role
$user = wp_get_current_user();
$percentage_fee = ($cart->cart_contents_total + $cart->shipping_total) * $discount_percentage;
$user_role = $user->roles; //Check the specifc user role for discount.
if (in_array($user_role[0], $set_role)) {
$cart->add_fee('הנחה באחוזים', -$percentage_fee, true);
}
}
add_action('woocommerce_cart_calculate_fees', 'sv_discount_price_percentage');
content_copyCOPY
Comments