Hi there i know this is an old post but hoping someone can help here as i’ve created a drop down box in the checkout all seems to work ok however i want it to be a required field i know i can use the
required = true line but as it already has an option selected as it just uses the first option on the list i have tried using a blank field but no joy
here is my code so far as i’m sure other would want to use this
echo '<div id="my_custom_checkout_field"><h3>'.__('How you found us').'</h3>';
woocommerce_form_field ( 'my_field_name', array(
'type' => 'select',
'class' => array('my-field-class form-row-wide'),
'label' => __('Choose an option'),
'placeholder' => _x('Phone', 'placeholder', 'woocommerce'),
'options' => array(
'option_a' => __( '','' ),
'option_b' => __('Google', 'Google' ),
'option_c' => __('Medical referral', 'Medical_referral' ),
'option_d' => __('Snorelab mobile app', 'Snorelab_mobile_app' ),
'option_e' => __('Bing', 'Bing' ),
'option_f' => __('Yahoo', 'Yahoo' ),
'option_g' => __('Leaflet', 'Leaflet' ),
'option_h' => __('Newsletter', 'Newsletter' ),
'option_i' => __('Other', 'Other' ),
),
'required' => true,
), $checkout->get_value( 'my_field_name' ));