【发布时间】:2015-03-14 22:13:34
【问题描述】:
好的,所以我正在尝试编写一个过滤器或挂钩,它将根据购物车中商品的总数量来修改购物车的总金额。例如,如果购物车中有三件商品,我想从总订单中扣除 20 美元。以下是我到目前为止的代码,非常感谢任何帮助!
add_filter('woocommerce_cart_contents_total', 'bundle_deals');
function bundle_deals( $cart_contents_total, $cart_contents_count) {
global $woocommerce;
if ($woocommerce->cart->get_cart()->cart_contents_count <= 3) {
$cart_contents_total = $woocommerce->cart->get_cart()->cart_contents_total - 20.00;
}
return $cart_contents_total;
}
【问题讨论】:
标签: php wordpress woocommerce