隐藏结帐流程中的国际税率标签

时间:2018-03-23 03:05:10

标签: php wordpress woocommerce checkout tax

我有一家商店,在全国(新西兰)和国际上销售。

我希望以一致的价格收取特定产品(例如,新西兰元4.95美元)

对于新西兰的订单,我需要能够强调价格新西兰元4.95美元包括0.65美元消费税(用于税务发票目的)。

对于国际订单,我需要它们以4.95新西兰元收费,但没有提及税收。

如果我使用以下标签设置了两项税:

  1. NZ GST 15%
  2. 国际价格调整15%
  3. 是否有可能隐藏所有提及的国际价格调整"从结账过程?

1 个答案:

答案 0 :(得分:2)

更新:以下代码将删除(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文件。经过测试并正常工作。

相关问题