Support » Plugin: Custom WooCommerce Checkout Fields Editor » Select field options missing values

  • Resolved Viszt Péter

    (@passatgt)


    Hi!

    On line 131 of class-wc-checkout-field-editor.php, the option for the default WooCommerce select is overwritten, but the value attribute is missing:

    $options .= '<option '. selected( $value, $option_key, false ) . '>' . esc_attr( $option_text ) .'</option>';

    Should be this instead:

    $options .= '<option '. selected( $value, $option_key, false ) . ' value="'.$option_key.'">' . esc_attr( $option_text ) .'</option>';

    And on line 141, the select name is appended with []:

    $field .= '<select name="' . esc_attr( $key ) . '[]" id="' . esc_attr( $key ) . '" class="checkout_chosen_select select wc-enhanced-select ' . $class . '">

    You can test with this code and see that the option value are missing:

    woocommerce_form_field( 'test', array(
    	'type'        => 'select',
    	'options'     => array(
    		'1' => '1',
    		'2' => '2'
    	),
    ), '2' );
    • This topic was modified 4 months, 1 week ago by Viszt Péter.
Viewing 1 replies (of 1 total)
  • Plugin Author themelocation

    (@themelocation)

    Thanks for suggesting missing things. we implement it at update version

    and line 141 the [] with name thing u mention. it’s because for the select field is passed array data. so that’s why we passed this symbol and here we don’t add woocommerce form field function because this was totally custom things.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.