簡體   English   中英

在 Woocommerce 客戶電子郵件通知中自定義總計行

[英]Customizing totals lines in Woocommerce customer email notifications

我的 woocommerce 發出了它應該的。

稅收字段如何顯示似乎是未關閉的標簽。

我已經瀏覽了整個 woocommerce 代碼,但找不到標簽的生成位置。

這就是我的稅務字段在電子郵件中的外觀。

 Total:     DKK 0.00 <small class="includes_tax"

這只能是您對訂單總數進行自定義的結果,或者是您的主題或插件正在制作的結果。 默認情況下,Woocommerce 中沒有這種行為。 在您的情況下,這似乎是由於插件(或某些自定義)將貨幣符號顯示為 Code

現在 Woocommerce 電子郵件通知中的訂單總計行是使用WC_Order方法get_order_item_totals()

然后您可以使用以下代碼對其進行更改:

add_filter( 'woocommerce_get_order_item_totals', 'customize_order_line_totals', 1000, 3 );
function customize_order_line_totals( $total_rows, $order, $tax_display ){
    // Only on emails notifications
    if( ! is_wc_endpoint_url() || ! is_admin() ) {

        // Remove any other html tags from gran total value
        $total_rows['order_total']['value'] = strip_tags( wc_price( $order->get_total() ) );
    }

    return $total_rows;
}

代碼位於活動子主題(或活動主題)的 function.php 文件中。 它應該可以解決您的問題。

但最好的方法應該是找出有罪的,而不是修補某個地方的某些自定義所做的錯誤。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM