[英]Customized Shipping section on cart and checkout page not showing in woocommerce email template
I have here a code that adds the " Total shipping cost " based on the shipping rate per product 我这里有一个代码,该代码根据每种产品的运费添加“ 总运费 ”
function action_woocommerce_after_shipping_rate( $method, $index ) {
global $woocommerce;
$sub_ed_total = preg_replace('/&.*?;/', '', WC()->cart->get_cart_subtotal());
$ed_total = preg_replace('/&.*?;/', '', WC()->cart->get_cart_total());
$str = preg_replace('/[^0-9.]+/', '', $sub_ed_total);
$str2 = preg_replace('/[^0-9.]+/', '', $ed_total);
$ed_tototal = $str - $str2;
echo '<br>';
echo 'Total shipping: '.get_woocommerce_currency_symbol().number_format((float)abs($ed_tototal), 2, '.', '');
echo '<br>';
echo '<br>';
};
add_action( 'woocommerce_after_shipping_rate', 'action_woocommerce_after_shipping_rate', 10, 2 );
Its working on my checkout page and cart page 它适用于我的结帐页面和购物车页面
and here is the email template after purchase 这是购买后的电子邮件模板
You see that in the email template the "Total shipping: £17.00" is not showing and I don't know how to make it show up in the email template 您会在电子邮件模板中看到“总运费:17.00英镑”未显示,并且我不知道如何在电子邮件模板中显示它
Please help as I am having a headache now trying to solve this problem, thanks 请帮忙,因为我现在正想解决此问题时头疼,谢谢
add_action( 'woocommerce_email_after_order_table', 'wdm_add_shipping_method_to_order_email', 10, 2 );
function wdm_add_shipping_method_to_order_email( $order, $is_admin_email ) {
echo '<p><h4>Shipping:</h4> ' . $order->get_shipping_method() . '</p>';
}
Using this you can override default text of shipping. 使用此功能,您可以覆盖默认的运输文字。 May this help.
可能会有所帮助。 You have to just replace $order->get_shipping_method() to your code.
您只需将$ order-> get_shipping_method()替换为您的代码即可。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.