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