-2
我試圖在結帳窗體的末尾添加一堆自定義字段,以收集我們需要處理訂單的其他數據。爲WooCommerce結帳後的訂單註釋添加選擇字段
這是我有:
add_action('woocommerce_after_order_notes', 'student_info_fields');
function student_info_fields($checkout) {
echo '<div id="student_info"><span>The following information below will be used to create an account.</span>';
//This adds a student_name field
woocommerce_form_field('student_name', array(
'type' => 'text',
'class' => array('form-row-wide'),
'label' => __('Student Name'),
'placeholder' => __('eg: "John Smith", "Johnny", etc'),
'required' => 'true',
), $checkout->get_value('student_name'));
/* I have two other text fields here that follow the same syntax as student_name */
//This adds a student_gender field
woocommerce_form_field('student_gender', array(
'type' => 'select',
'label' => __('Gender', 'woocommerce'),
'placeholder' => _x('', 'placeholder', 'woocommerce'),
'required' => 'true',
'options' => array(
'male' => __('Male', 'woocommerce'),
'female' => __('Female', 'woocommerce')
),
), $checkout->get_value('student_gender'));
echo '</div>';
}
的文本字段都似乎工作,但是當我加入student_gender場,我的分頁符(全白畫面)。通過在數組中調用options
數組以及在聲明每個字段後調用$checkout ->get_value...
一行,我有點偏離了目標,但我根本不知道該怎麼做。
你可以給我的任何方向將有助於破解這個堅果。感謝您的支持!
看看你的服務器的錯誤日誌知道確切的錯誤。可能這會給你所有你需要的信息。如果不是,請回到問題中並粘貼錯誤。 –