簡體   English   中英

Woocommerce 電子郵件自定義字段未顯示在表格中

[英]Woocommerce Email Custom field not display in table

我使用 woocommerce 在 wordpress 中創建了一個站點,並在結帳頁面中添加了自定義字段,也在結帳后的電子郵件中添加了自定義字段。

但問題是自定義數據(交付方法)字段未顯示在 woocommerce 生成的電子郵件中的表格下方。

請幫我解決這個問題。

在此處輸入圖片說明

這是我的代碼

add_filter('woocommerce_email_order_meta_keys', 'my_woocommerce_email_order_meta_keys');

function my_woocommerce_email_order_meta_keys($keys)
{
    $keys['Delivery Method'] = 'delivery_options';
    return $keys;
}

羅賓,

我已經嘗試了您的問題的一種解決方案,希望這對您有用。

我試過的解決方案(它對我有用)

/*This is action hook for adding content before the mail template footer*/
add_action( 'woocommerce_email_footer', 'custom_email_footer', 10, 1 );

function custom_email_footer( $email ) {
 /*$_POST['billing_delivery_date'] (My custom field variable)*/

 if (isset($_POST['billing_delivery_date'])) { /*Get value of the custom field*/

  /*Echo the filed value with some string or as you want*/
   echo "Delivery date : ".$_POST['billing_delivery_date'];
 }
}
  • 理解

    有幾個 woo-commerce 掛鈎可用於將自定義數據添加到通過郵件發送的電子郵件模板。

    注意:我也使用了其中之一。 :-)

此外,您使用的鈎子將按照優先級的順序生成自定義字段或將其添加到電子郵件模板中。

  • 截圖 1

    使用鈎子之前/使用鈎子時: 前圖像

  • 截圖 2

    使用 (woocommerce_email_footer) 鈎子后: 后圖像

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM