2
我正在尝试为WooCommerce提供一个简单的折扣代码,在购买之前给您一个百分比折扣。比方说,如果你增加产品价值$ 100,您获得2%的折扣,如果你增加产品价值$ 250,你得到4%等基于购物车金额的渐进式百分比折扣
我发现的唯一的事情是这样的:
// Hook before calculate fees
add_action('woocommerce_cart_calculate_fees' , 'add_custom_fees');
/**
* Add custom fee if more than three article
* @param WC_Cart $cart
*/
function add_custom_fees(WC_Cart $cart){
if($cart->cart_contents_count < 3){
return;
}
// Calculate the amount to reduce
$discount = $cart->subtotal * 0.1;
$cart->add_fee('You have more than 3 items in your cart, a 10% discount has been added.', -$discount);
}
,但不能设法使其与修改与价格挂钩的工作。
我该如何做到这一点?
感谢。
哇,那真的很有帮助。非常感谢! –
有什么方法可以在购物车中显示折扣吗? –
折扣只出现在我的结帐页面,购物车价格显示是没有折扣的全价。 –