我有一家在国内(新西兰)和国际上销售的商店。
我希望给定产品以一致的价格收费(例如 NZD$4.95)
对于新西兰订单,我需要强调这样一个事实:4.95 新西兰元的价格包含 0.65 美元的商品及服务税(用于税务发票)。
对于国际订单,我需要收取 4.95 新西兰元的费用,但没有提及税费。
如果我设置了两种带有以下标签的税:
是否可以在结帐过程中隐藏所有提及“国际价格调整”的内容?
更新:以下代码将删除购物车、结帐、订单和电子邮件通知上的
(includes NZD $0.65 International Price Adjustment 15%)
税行国际客户:
// For Cart and checkout pages
add_filter( 'woocommerce_cart_totals_order_total_html', 'hide_iternational_tax_label', 20, 1 );
function hide_iternational_tax_label( $value ) {
// For international orders we display only the total, not the taxes line below
if( 'NZ' != WC()->customer->get_billing_country() )
return '<strong>' . WC()->cart->get_total() . '</strong> ';
return $value;
}
// For customer Order received, Order view and email notifications
add_filter( 'woocommerce_get_formatted_order_total', 'hide_iternational_order_tax_label', 20, 4 );
function hide_iternational_order_tax_label( $formatted_total, $order, $tax_display, $display_refunded ) {
// For international orders we display only the total, not the taxes line below
if( 'NZ' != $order->get_billing_country() ){
$tax_string = ''; // <=== nulling the tax string
$order_total = $order->get_total();
$formatted_total = wc_price( $order_total, array( 'currency' => $order->get_currency() ) );
$total_refunded = $order->get_total_refunded();
if ( $total_refunded && $display_refunded ) {
$formatted_total = '<del>' . strip_tags( $formatted_total ) . '</del> <ins>' . wc_price( $order_total - $total_refunded, array( 'currency' => $order->get_currency() ) ) . $tax_string . '</ins>';
} else {
$formatted_total .= $tax_string;
}
}
return $formatted_total;
}
代码位于活动子主题(或活动主题)的 function.php 文件中。已测试且有效。