2017-06-30 120 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' 
      ); 

     } 
    } 

} 

回答

相关问题