【发布时间】:2020-07-11 16:25:51
【问题描述】:
我已为英国的某人设置了 3 件商品的免费送货门槛。每次有人添加特定类别的产品时,我都会自动将产品添加到他们的购物车中,这是免费礼物。
我的问题是,我试图从阈值计数中排除此免费礼物,因为目前正在计算此免费礼物,并且人们在购物车中没有 3 件实际收费物品的情况下获得免费送货。
我不确定如何从计数中排除产品 id 29,因此我们将不胜感激。
add_action( 'woocommerce_before_cart', 'ds_free_shipping_cart_notice' );
function ds_free_shipping_cart_notice() {
$threshold = 3;
$current = WC()->cart->get_cart_contents_count();
$billing_country = WC()->customer->get_billing_country();
if ( $current < $threshold && WC()->customer->get_billing_country() == 'GB' ) {
wc_print_notice( 'Nearly there! Order ' . ( $threshold - $current ) . ' more and shipping is on us', 'notice' );
}
}
【问题讨论】:
标签: php woocommerce