'woocommerce checkout page custom dropdown field data not showing in frontend
I get data from the database in woocommerce checkout page custom dropdown field, data is coming in options I can show in inspact mode but it is not showing in the frontend.
##here is my code in functions.php
add_action( 'woocommerce_after_order_notes', 'cliente_woocommerce', 999999, 1);
function cliente_woocommerce( $checkout ) {
global $wpdb;
$table_name = $wpdb->prefix . 'postcode';
$results = $wpdb->get_results( "SELECT * FROM $table_name" );
$options = array( '' => __('') );
// Loop through the data query results
foreach($results as $result) {
$options[$result->postcode_name .' from ' . $result->miles] = $result->zipcode;
}
echo '<div id="cliente_woocommerce"><h2>' . __('Zip code 5 mile radius') . '</h2>';
woocommerce_form_field( 'postcode', array(
'type' => 'select',
'class' => array('cliente form-row-wide'),
'label' => __('Zipcode '),
'options' => $options,
), $checkout->get_value( 'postcode' ) );
return $checkout;
echo '</div>';
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
