Woocommerce Checkout: Add placeholder in country dropdown [duplicate] Woocommerce Checkout: Add placeholder in country dropdown [duplicate] wordpress wordpress

Woocommerce Checkout: Add placeholder in country dropdown [duplicate]


This is working for my side try this

// Change the default country and state on checkout page. // This works for a new session.add_filter( 'default_checkout_country', 'xa_set_default_checkout_country' );add_filter( 'default_checkout_state', 'xa_set_default_checkout_state' );function xa_set_default_checkout_country() {  // Returns empty country by default.    return null;  // Returns India as default country.     // return 'IN';}function xa_set_default_checkout_state() {  // Returns empty state by default.    return null;  // Returns Madhya Pradesh as default state.     // return 'MP';}function woo_add_my_country( $country ) {   $country["PLACE"] = 'select your country*';   return $country;}add_filter( 'woocommerce_countries', 'woo_add_my_country', 10, 1 );add_filter( 'default_checkout_billing_country', 'bbloomer_change_default_checkout_country' );function bbloomer_change_default_checkout_country() {  return 'PLACE'; }


Just go to WooCommerce > Settings.On General tab you will find Default customer location. Set it to No location by default

enter image description here


This was one of the first results that popped up for me when searching how to set a placeholder for a select field on the Woocommerce checkout page, so for any future visitors:

I have a company select field that I populate dynamically with values from the database. In order to set a placeholder value, I just add an option with a blank value.

add_filter( 'woocommerce_checkout_fields' , 'populate_company_field' );function populate_company_field($fields) {  $results = get_results_from_database();  $options[''] = __('Choose your company', 'gs'); //add blank value = placeholder  foreach ($results as $result) {    if (!empty($result->company)) {        $options[$result->ID] = $result->company;    }  }  $fields['billing']['company']['options'] = $options;  return $fields;}