8manos/wc-city-select

Multilingual WooCommerce issue

Opened this issue · 1 comments

Hi,
I'm using wc-city-select on multilingual WooCommerce website.

The issue is while user ordered, city will stored in the user language, and it will cause some issues with shipping plugins, city should be always English.

I tried to solve it by editing this :
foreach ( $this->dropdown_cities as $city_name ) { $field .= '<option value="' . $city_name. '" '.selected( $value, $city_name, false ) . '>' . $city_name .'</option>'; }

and replace it with:
foreach ( $this->dropdown_cities as $index => $city_name ) { $field .= '<option value="' . $index . '" '.selected( $value, $city_name, false ) . '>' . $city_name .'</option>'; }

and another edit on the cities array :
$cities['SA'] = array( 'Riyadh' => array( 'Riyadh' => __('Riyadh','wc_cities_p'), ));

by this way, index will be always in English language, and city will be compatible with WPML..etc

But, it actually didn't work because the first section does not appear on the HTML, I mean the billing_city or shipping_city select element always showing the original one.

where can I find this elements loop to edit it?

hey, I think I get what you mean, but I'm not sure what loop you're asking about...
Take a look here: https://github.com/8manos/wc-city-select/blob/master/assets/js/city-select.js#L166
The plugin uses javascript to change the list of cities according to the country/state selected.