在 WooCommerce 中,基于“ WooCommerce 中的動態(tài)同步自定義結帳選擇字段”答案代碼,我在結帳時添加了一些自定義字段,這些字段將顯示在電子郵件確認的賬單部分下這是我的實際代碼:add_action( 'woocommerce_after_checkout_billing_form', 'add_checkout_custom_fields', 20, 1 );function add_checkout_custom_fields( $checkout) { $domain = 'woocommerce'; // The domain slug // First Select field (Master) woocommerce_form_field( 'delivery_one', array( 'type' => 'select', 'label' => __( 'Art der Lieferung' , $domain), 'class' => array( 'form-row-first' ), 'required' => true, 'options' => array( '' => __( 'W?hlen Art der Lieferung.', $domain ), 'A' => __( 'Hauszustellung', $domain ), 'B' => __( 'Selbst Abholung', $domain ), ), ), $checkout->get_value( 'delivery_one' ) ); // Default option value $default_option2 = __( 'W?hlen Sie Zeitbereich.', $domain ); // Dynamic select field options for Javascript/jQuery $options_0 = array( '' => $default_option2 ); $options_a = array( '' => $default_option2, '1' => __( '09:00-11:00', $domain ), '2' => __( '10:00-12:00', $domain ), '3' => __( '11:00-13:00', $domain ), '4' => __( '12:00-14:00', $domain ), '5' => __( '13:00-15:00', $domain ), '6' => __( '14:00-16:00', $domain ), '7' => __( '15:00-17:00', $domain ), );我的自定義字段及其值顯示在結帳表單和后端的訂單頁面上。到目前為止,一切都很好。但問題是我收到的電子郵件不包含自定義字段及其值。如何在電子郵件通知中顯示自定義結帳賬單字段?這段代碼正確嗎?
2 回答

牧羊人nacy
TA貢獻1862條經(jīng)驗 獲得超7個贊
您應該首先將輸入值保存在數(shù)據(jù)庫中作為訂單元,請參見此處,然后您可以在電子郵件模板中獲取元值。woocommerce 的所有電子郵件模板都是可定制的,位于plugins/woocommerce/emails/
您可以使用此鉤子在訂單元存儲自定義輸入字段
do_action( 'woocommerce_checkout_order_processed', $order_id, $posted_data, $order );
謝謝
- 2 回答
- 0 關注
- 159 瀏覽
添加回答
舉報
0/150
提交
取消