2016-09-13 77 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

相關問題