2017-08-17 127 views

回答

1

使用woocommerce_calculate_totals動作鉤子鉤住這個自定義函數,你會從車總計(只是在購物車頁面顯示)中排除運費

// For WooCommerce versions from 2.5.x up to 3+ 
add_action('woocommerce_calculate_totals', 'custom_cart_displayed_totals', 10, 1); 
function custom_cart_displayed_totals($cart_object) { 

    if (is_admin() && ! defined('DOING_AJAX')) 
     return; 

    // Only on cart page 
    if (! WC()->cart->is_empty() && is_cart()): 

     ## Get The shipping totals 
     $shipping_tax_amount = $cart_object->shipping_total; 
     $shipping_total_excl_tax = $cart_object->shipping_tax_total; 

     ## Displayed subtotal 
     // $cart_object->subtotal = 0; 

     ## Displayed TOTAL 
     // $cart_object->total = 0; 

     ## Displayed TOTAL 
     $cart_object->tax_total -= $shipping_tax_amount; 

     ## Displayed TOTAL 
     $cart_object->cart_contents_total -= $shipping_total_excl_tax; 

    endif; 
} 

代碼放在功能。你的活動兒童主題(或主題)的php文件或任何插件文件。

測試和工作...