0
在發送給客戶的每個電子郵件通知中,告知他們其訂單正在處理中(假設SKU已啓用),它將在括號中顯示產品名稱旁邊的SKU。我希望它在這種情況下顯示一個自定義字段,其中的商品ID與SKU不同。將SKU更改爲自定義字段,以便處理電子郵件通知
我已經進入了customer-processing-order.php文件,並試圖在標題之後獲取meta,但是這隻會拋出該數組的id#而不是顯示該字段的數據。例如,在下面我們該模板有:
<tr>
<th scope="col" style="text-align:left; border: 1px solid #eee;"><?php _e('Product', 'woocommerce'); ?></th>
<th scope="col" style="text-align:left; border: 1px solid #eee;"><?php _e('Quantity', 'woocommerce'); ?></th>
<th scope="col" style="text-align:left; border: 1px solid #eee;"><?php _e('Price', 'woocommerce'); ?></th>
</tr>
如果將其更改爲類似:
<tr>
<th scope="col" style="text-align:left; border: 1px solid #eee;"><?php _e('Product', 'woocommerce'); ?> <?php the_field('item_id'); ?></th>
<th scope="col" style="text-align:left; border: 1px solid #eee;"><?php _e('Quantity', 'woocommerce'); ?></th>
<th scope="col" style="text-align:left; border: 1px solid #eee;"><?php _e('Price', 'woocommerce'); ?></th>
</tr>
它只是顯示陣列ID而不是實際的場輸出。我想找到一個更乾淨的方法,我可以把它放到一個函數文件中,但我找不到任何解決方案。
當你說 「這只是顯示陣列ID」 你的意思是一個整數?是the_field('item_id')返回一個數組?如果是這樣,你是否總是想要數組中的相同元素? – 2015-01-26 18:59:50
是的,是的。我總是希望它顯示訂購產品的「商品ID」字段中的內容。因此,如果他們購買了兩個不同的物品,他們都會從該元字段中獲取自己的唯一物品ID。 – partiallypro 2015-01-26 21:04:52
可以粘貼print_r(the_field('item_id'))的輸出嗎? – 2015-01-26 21:13:17