2016-09-13 78 views
0

在WooCommerce中,我的谢谢页面上有问题(一旦客户下了订单)。我试图改变它manualy,但问题是,代码是在一个未知的文件,我找不到。WooCommerce - 在Thankyou订单上自定义“Total”文本收到页面

<tfoot> 
     <?php 
       foreach ($order->get_order_item_totals() as $key => $total) { 
        ?> 
        <tr> 
         <th scope="row"><?php echo $total['label']; ?></th> 
         <td><?php echo $total['value']; ?></td> 
        </tr> 
        <?php 
       } 
      ?> 
    </tfoot> 

此代码给我像优惠券我的订单的所有信息航运等

enter image description here

在这张照片我想换成黑色边矩形文本(这里'Gesamt:'意味着"Total"通过"Total inkl. vat"

另外我想删除红色有边框的矩形块:"Inkl. 19% MwSt."

可能吗?
我该怎么做?

谢谢。

回答

2

这里说的是在加载结束对woocommerce/order/order-details.php模板提取谢谢页。

要覆盖由foreach循环利用施加到$order对象(即产生的key/values阵列)方法get_order_item_totals()显示'Total'文本,则必须添加一个您的网站使用的每种语言的条件。在我的代码中,你有英语和德语。

在你活动的主题去woocommerce > order,并打开/编辑 order-details.php模板文件。

替换模板结束本:

<tfoot> 
     <?php 
      $order_item_totals = $order->get_order_item_totals(); 
      $count_lines = count($order_item_totals) - 1; 
      $count = 0; 
      foreach ($order_item_totals as $key => $total) { 
       $count++; 
       // The condition to replace "Total:" text in english and german 
       if($total['label'] == 'Total:' || $total['label'] == 'Gesamt:') 
        $total_label = __('Total inkl. vat:', 'woocommerce'); 
       else 
        $total_label = $total['label']; 
       // End of the condition 
       ?> 
       <tr> 
        <th scope="row"><?php echo $total_label; // <== == Replaced $total['label'] by $total_label ?></th> 
        <td><?php echo $total['value']; ?></td> 
       </tr> 
       <?php 
       // this should avoid displaying last line 
       if($count >= $count_lines) break; 
      } 
     ?> 
    </tfoot> 
</table> 

<?php do_action('woocommerce_order_details_after_order_table', $order); ?> 

<?php if ($show_customer_details) : ?> 
    <?php wc_get_template('order/order-details-customer.php', array('order' => $order)); ?> 
<?php endif; ?> 

现在您可以保存,你做......

该代码测试和工程。

参考文献:

+0

谢谢!你知道现在从这个网站删除额外描述增值税的方法吗?谢谢 – Johnny97

+0

我可以写信给你,但我会在这里回答,因为如果其他人需要这个答案,你知道吗?我的意思是我的照片中的红色矩形区域。首先我已经添加了incl。大桶总标签,现在我想从这个循环中删除红色领域,因为我不想显示增值税 – Johnny97

+0

@ Johnny97我完全理解**完全**现在您的问题。所以我已经更新了你的问题,使其更清楚并更新了我的答案(你必须测试它,因为我没有)。如果它有效,请在这里评论我。 – LoicTheAztec

1

嘿,我认为这会为你工作

只要确保inkl. 19%....编写正确。

foreach ($order->get_order_item_totals() as $key => $total) { 
    ?> 
    <tr> 
     <th scope="row"><?php echo ($total['label']=='inkl. 19% Mwst.'?'Vat Only':$total['label']); ?></th> 
     <td><?php echo $total['value']; ?></td> 
    </tr> 
    <?php 
} 
+0

谢谢你的帮助呢! – Johnny97

相关问题