如果他们是会员,我会以编程方式为Woocommerce订单添加折扣,如下所示:
function member_discount($cart) {
/* Code to check if user is a member here */
$memberdiscount = 0.05;
// Get total cart amount
$carttotal = $cart->cart_contents_total;
// Calculate numbered discount
$discount = $carttotal * $memberdiscount;
// Alter the cart discount total
$cart->discount_total = $cart->discount_total + $discount;
}
add_action('woocommerce_calculate_totals', 'member_discount');
但是,当我购买价值10英镑的产品并且用户是会员(从而获得5%的折扣)时,订单会显示以下内容,而不会提及折扣的原因:
购物车小计£10.00
订单总额£9.50
最棒的是:
购物车小计£10.00
会员折扣£0.50
订单总额£9.50
或者愚弄woocommerce以认为已经应用了优惠券代码:
购物车小计£10.00
优惠券:会员折扣£0.50
订单总额£9.50
有人知道这是否可行?