Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在商业订单电子邮件中隐藏增值税标签和价值?_Php_Wordpress_Woocommerce - Fatal编程技术网

Php 如何在商业订单电子邮件中隐藏增值税标签和价值?

Php 如何在商业订单电子邮件中隐藏增值税标签和价值?,php,wordpress,woocommerce,Php,Wordpress,Woocommerce,我想隐藏或删除商业订单电子邮件中的增值税(税)行。结果来自此函数“get_order_item_totals()”。我已经可以使用下面的代码在电子邮件中隐藏税务标签了 function sv_change_email_tax_label( $label ) { $label = ''; return $label; } add_filter( 'woocommerce_countries_tax_or_vat', 'sv_change_email_tax_label'

我想隐藏或删除商业订单电子邮件中的增值税(税)行。结果来自此函数“get_order_item_totals()”。我已经可以使用下面的代码在电子邮件中隐藏税务标签了

function sv_change_email_tax_label( $label ) {
    $label = '';
    return $label;
}
add_filter( 'woocommerce_countries_tax_or_vat', 'sv_change_email_tax_label'       );

我想对订单邮件隐藏整行增值税

根据订单的状态,您需要编辑相关的电子邮件模板

<?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                  
      }
   }
 ?>
例如:如果启用了COD付款方式,并且客户选择了该选项,则订单状态将为“正在处理”,在这种情况下,您需要编辑
customer Processing order.php
template

//find this line and after it add the following line of code                
foreach ( $totals as $total ) {  

    //ensure to change "VAT" with the label that appears on your email
    if( strstr( $total['label'], "VAT" ) )  continue; 

终于想出了一个办法。“get_order_item_totals()”函数返回数组数组。所以我取消设置了不需要的数组。在这种情况下,$总计[税] 以下是我在电子邮件模板中的代码

<?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                  
      }
   }
 ?>

非常感谢所有试图帮助你的人!
问候

他们使用wp_邮件,所以是可插拔的。。。只需在函数中编辑该部分。谢谢你的回答。我所做的一切都是未定的($totals[税]);在foreach之前。