1
我正在尝试设置最低订单金额为25美元。到目前为止,我发现了这个代码,如果最小值没有达到,这似乎可以阻止结帐,但是它使用的小计是含税,我需要排除总计中的税。在Woocommerce购物车中设置最小小计金额
add_action('woocommerce_checkout_process', 'wc_minimum_order_amount');
add_action('woocommerce_before_cart' , 'wc_minimum_order_amount');
function wc_minimum_order_amount() {
// Set this variable to specify a minimum order value
$minimum = 25;
if (WC()->cart->subtotal < $minimum) {
if(is_cart()) {
wc_print_notice(
sprintf('You must have an order with a minimum of %s to place your order, your current order total is %s.' ,
wc_price($minimum),
wc_price(WC()->cart->subtotal)
), 'error'
);
} else {
wc_add_notice(
sprintf('You must have an order with a minimum of %s to place your order, your current order total is %s.' ,
wc_price($minimum),
wc_price(WC()->cart->subtotal)
), 'error'
);
}
}
}
谢谢!这工作完美!我在网上到处搜索,无法找到这个简单的代码行来排除税收。 – bworkman
@bworkman你打赌!很高兴它的工作。 API源文件始终是一个肯定的选择,只需要一些时间来挖掘和测试。 – Chasevanb