2016-11-08 148 views
0

,我有以下功能附加選擇列表中的宇商貿結算形式:Woocommerce結帳的自定義選擇字段

woocommerce_form_field('airport_pickup', array(
     'type'   => 'select', 
     'class'   => array('airport_pickup form-row-wide'), 
     'label'   => __('Would you like us to arrange transportation from the airport to your starting hotel?'), 
     'required' => true, 
     'options'  => array(
     'Y' => __('YES'), 
     'N' => __('NO') 
     )), $checkout->get_value('airport_pickup')); 

我想提出由default.Please選擇了「否」的選擇建議。怎麼做?

回答

3

下面是woocommerce_form_field的默認參數($參數)($鍵,$ ARGS,$ value)函數:

$defaults = array( 
    'type' => 'text', 
    'label' => '', 
    'description' => '', 
    'placeholder' => '', 
    'maxlength' => false, 
    'required' => false, 
    'autocomplete' => false, 
    'id' => $key, 
    'class' => array(), 
    'label_class' => array(), 
    'input_class' => array(), 
    'return' => false, 
    'options' => array(), 
    'custom_attributes' => array(), 
    'validate' => array(), 
    'default' => '', 
); 

在你的情況,你只需要修改如下:

woocommerce_form_field('airport_pickup', array(
    'type'   => 'select', 
    'class'   => array('airport_pickup form-row-wide'), 
    'label'   => __('Would you like us to arrange transportation from the airport to your starting hotel?'), 
    'required' => true, 
    'options'  => array(
         'Y' => __('YES'), 
         'N' => __('NO') 
    ), 
    'default' => 'N'), 
    $checkout->get_value('airport_pickup')); 

希望它有幫助!

+0

是的,它正在工作。謝謝 –

+1

酷!不要忘記將問題標記爲已解決。 – Benoti

相關問題