你如何在WooCommerce稅收總額中的WordPress functions.php
頁,使用:找車總稅額編程方式WooCommerce
global $woocommerce;
$discount = $woocommerce->cart->tax_total;
但沒有返回任何值。
如何獲得購物車稅總額?
本質上我想稅收爲用戶計算,但隨後它會減少,因爲客戶將支付COD的稅收。
全部下面的代碼:
add_action('woocommerce_calculate_totals', 'action_cart_calculate_totals', 10, 1);
function action_cart_calculate_totals($cart_object) {
if (is_admin() && ! defined('DOING_AJAX'))
return;
if (!WC()->cart->is_empty()):
$cart_object->cart_contents_total *= .10 ;
endif;
}
//Code for removing tax from total collected
function prefix_add_discount_line($cart) {
global $woocommerce;
$discount = $woocommerce->cart->tax_total;
$woocommerce->cart->add_fee(__('Tax Paid On COD', 'your-text-domain') , - $discount);
}
add_action('woocommerce_cart_calculate_fees', 'prefix_add_discount_line');
再次你真棒,謝謝 – DEVPROCB