更改“运费"Woocommerce 电子邮件表总计中的标签? [英] Change "Shipping" label in Woocommerce email table totals?
问题描述
我正在 WooCommerce 中自定义订单电子邮件模板,需要将Shipping"标题更改为Delivery",并将Shipping address"更改为Delivery address".我尝试了一个插件,说什么"可以改变文本,但它没有用.有一个循环来处理所有这些信息.
I am customizing the order email template in WooCommerce and need to change the title of "Shipping" to "Delivery," as well as change "Shipping address" to "Delivery address". I tried a plugin, "Say What" that would change the text but it did not work. There is a loop that handles all of this information.
这是email-order-details.php"页面第52行的代码.
This is the code on line 52 in the "email-order-details.php" page.
if ( $totals = $order->get_order_item_totals() ) {
$i = 0;
foreach ( $totals as $total ) {
$i++;
if($total['label'] === "Shipping"){
//make second-last above total somehow
}
else{
?><tr>
<th class="td" scope="row" colspan="3" style="text-align:<?php echo $text_align; ?>; <?php echo ( 1 === $i ) ? 'border-top-width: 4px;' : ''; ?>"><?php echo $total['label']; ?></th>
<td class="td" style="text-align:left; <?php echo ( 1 === $i ) ? 'border-top-width: 4px;' : ''; ?>" colspan="1"><?php echo $total['value']; ?></td>
</tr><?php
}
}
}
我认为这是一个过滤器钩子,但我不知道如何使用它.
I assume this is a filter hook, but I am not sure how to use it.
woocommerce_get_order_item_totals
推荐答案
可以使用以下挂钩函数来完成:
It can be done using the following hooked function:
add_filter( 'woocommerce_get_order_item_totals', 'renaming_shipping_order_item_totals', 10, 3 );
function renaming_shipping_order_item_totals( $total_rows, $order, $tax_display ){
// Only on emails notifications
if( ! is_wc_endpoint_url() )
$total_rows['shipping']['label'] = __('Delivery', 'woocommerce');
return $total_rows;
}
代码位于活动子主题(或活动主题)的 function.php 文件中.经测试有效.
Code goes in function.php file of your active child theme (or active theme). Tested and works.
要将送货地址"标签更改为送货地址",您需要复制/编辑模板email-addresses.php
,替换:
To change the "Shipping address" label to "Delivery address" you need to copy/edit the template email-addresses.php
, replacing:
_e( 'Shipping address', 'woocommerce' );
作者:
_e( 'Delivery address', 'woocommerce' );
这篇关于更改“运费"Woocommerce 电子邮件表总计中的标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!