如何从 WooCommerce 订单电子邮件中隐藏增值税标签和价值? [英] How to hide VAT label and value from WooCommerce order emails?
问题描述
我想隐藏或删除 WooCommerce 订单电子邮件中的增值税(税)行.结果来自这个函数get_order_item_totals()".我已经可以使用以下代码从电子邮件中隐藏税务标签.
I want to hide or remove VAT (tax) line from WooCommerce order emails. Result comes out from this function "get_order_item_totals()". Already I can hide tax label from emails by using following code.
function sv_change_email_tax_label( $label ) {
$label = '';
return $label;
}
add_filter( 'woocommerce_countries_tax_or_vat', 'sv_change_email_tax_label' );
我想在订单电子邮件中隐藏整行增值税.
I want to hide the entire row of VAT from order emails.
推荐答案
终于想出了一个办法.get_order_item_totals()"函数返回一个数组数组.所以我 unset() 不需要的数组.在这种情况下 $totals[tax]以下是我在电子邮件模板中的代码.
Finally figured out a way do this. "get_order_item_totals()" function returns an Array of arrays. so i unset() the unwanted array. in this case $totals[tax] following is my code in email template.
<?php
if ( $totals = $order->get_order_item_totals() ) {
unset($totals[tax]);
$i = 0;
foreach ( $totals as $total ) {
$i++;
?><tr>
<th scope="row" colspan="2" style="text-align:left; border: 1px solid #eee; <?php if ( $i == 1 ) echo 'border-top-width: 4px;'; ?>"><?php echo $total['label']; ?></th>
<td style="text-align:left; border: 1px solid #eee; <?php if ( $i == 1 ) echo 'border-top-width: 4px;'; ?>"><?php echo $total['value']; ?></td>
</tr><?php
}
}
?>
非常感谢所有试图提供帮助的人!问候!
Thank you very much everyone who tried to help! Regards!
这篇关于如何从 WooCommerce 订单电子邮件中隐藏增值税标签和价值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!