问题描述
我尝试了与How to hide VAT label and value from WooCommerce order emails?不同的答案代码,但是没有一个起作用。
解决方法
您可以使用以下非常简单的代码从WooCommerce电子邮件的订单行总计中删除格式化的税费信息:
add_filter( 'woocommerce_get_formatted_order_total','change_emails_formatted_order_total',10,2 );
function change_emails_formatted_order_total( $formatted_total,$order ) {
// Remove from order total the formatted taxes displayed on emails notifications only
return is_wc_endpoint_url() ? $formatted_total : wc_price( $order->get_total(),array( 'currency' => $order->get_currency() ) );
}
代码进入活动子主题(或活动主题)的functions.php文件中。经过测试,可以正常工作。
添加:要在订单行总金额替换后显示自定义文本:
return is_wc_endpoint_url() ? $formatted_total : wc_price( $order->get_total(),array( 'currency' => $order->get_currency() ) );
简单地:
return is_wc_endpoint_url() ? $formatted_total : wc_price( $order->get_total(),array( 'currency' => $order->get_currency() ) ) . ' ' . __("VAT included","woocommerce");
,
我爱你,非常感谢你。