2017-06-30 121 views
1

我正在嘗試設置最低訂單金額爲25美元。到目前爲止,我發現了這個代碼,如果最小值沒有達到,這似乎可以阻止結帳,但是它使用的小計是含稅,我需要排除總計中的稅。在Woocommerce購物車中設置最小小計金額


enter image description here


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' 
      ); 

     } 
    } 

} 

回答

相關問題