Auf der Suche nach Drop-Down-Land/Staat/Stadt. Ich bekomme Land State automatisch bevölkert, aber Städte nicht gut durch. Standardmäßig kann Land abgerufen werden.Drop-Down von Auto-Werten Land/Staat/Stadt Woocommerce Storefront
// State-Country additions
/**
* Code goes in functions.php or a custom plugin.
*/
add_filter('woocommerce_states', 'SA_woocommerce_states');
function SA_woocommerce_states($states) {
$states['ZA'] = array(
'EC' => __('Eastern Cape', 'woocommerce'),
);
return $states;
}
// Change "city" checkout billing and shipping fields to a dropdown
add_filter('woocommerce_checkout_fields', 'override_checkout_city_fields');
function override_checkout_city_fields($fields) {
// Define here in the array your desired cities (Here an example of cities)
$option_cities = array(
'' => __('Select your city'),
'a' => 'a',
);
$fields['billing']['billing_city']['type'] = 'select';
$fields['billing']['billing_city']['options'] = $option_cities;
$fields['shipping']['shipping_city']['type'] = 'select';
$fields['shipping']['shipping_city']['options'] = $option_cities;
return $fields;
}
Dies ist kein vollständiges Beispiel ist, so dass wir nicht reproduzieren können dein problem leicht. Bitte erläutern Sie, was Ihr Code tut und was Sie stattdessen erwarten. – JHBonarius
Bitte erläutern Sie, was Sie erreichen möchten. –