2017-04-19 94 views
1

我尝试了取消设置代码,但随后也删除了总计。我想留下总计并移除运费总计。从Woocommerce的新订单电子邮件中删除“运送小计”

<?php 
    if ($totals = $order->get_order_item_totals()) { 
     $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 
     } 
    } 
?> 

我似乎无法找到解决方案。有什么建议么?

谢谢。

回答

1

要删除航运大部线试试这个代码,而不是:

<?php 

if ($totals = $order->get_order_item_totals()) { 
    $i = 0; 
    foreach ($totals as $total_key => $total) { // Changed HERE 
     $i++; 
     if('shipping' != $total_key){ // Added HERE 
     ?><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 
     } // Added HERE 
    } 
} 

?> 

或者你可以使用unset() PHP函数:

<?php 

if ($totals = $order->get_order_item_totals()) { 
    unset(totals['shipping']) // HERE 
    $i = 0; 
    foreach ($totals as $total_key => $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 
} 

?> 
相关问题