代码之家  ›  专栏  ›  技术社区  ›  warm__tape

从签出过程中隐藏国际税率标签

  •  1
  • warm__tape  · 技术社区  · 7 年前

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

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

    对于新西兰订单,我需要强调一个事实,即4.95新西兰元的价格包括0.65新西兰商品及服务税(用于税务发票)。

    对于国际订单,我需要收取4.95新西兰元的费用,但不含税。

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

    1. 新西兰GST 15%
    2. 国际价格调整15%

    有没有可能在结账过程中隐藏所有关于“国际价格调整”的内容?

    1 回复  |  直到 7 年前
        1
  •  2
  •   LoicTheAztec    7 年前

    更新时间: 将删除以下代码 (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;
    }
    

    代码进入功能。活动子主题(或活动主题)的php文件。 已测试并正常工作。