2
我需要在購物車中設置最低訂單費用,因此如果購物車中的產品總價格不超過10英鎊,則需要支付額外費用才能將價格提高到10英鎊。WooCommerce基於動態最低訂單金額的費用
這裏是我目前在購物車階段運作良好的代碼,但是當您到達結賬處時,定價部分因某種原因不會停止加載,您無法結帳,任何人都可以幫忙嗎?從functions.php的
代碼:
你正面臨function woocommerce_custom_surcharge() {
global $woocommerce;
if (is_admin() && ! defined('DOING_AJAX'))
return;
$minimumprice = 10;
$currentprice = $woocommerce->cart->cart_contents_total;
$additionalfee = $minimumprice - $currentprice;
if ($additionalfee >= 0) {
wc_print_notice(
sprintf('We have a minimum %s per order. As your current order is only %s, an additional fee will be applied at checkout.' ,
wc_price($minimumprice),
wc_price($currentprice)
), 'error'
);
$woocommerce->cart->add_fee('Minimum Order Adjustment', $additionalfee, true, '');
}
}
add_action('woocommerce_cart_calculate_fees','woocommerce_custom_surcharge');