Override shipping/billing city
Override shipping/billing city with custom city list
1. Visit “Settings” – “Custom fields” and add to section “Customer fields” following text (edit list for your needs)
1 |
City|city|select|CityName1|CityName2|CityName3|CityName4 |
2. Add following PHP code to functions.php
1 2 3 4 5 6 7 8 9 10 |
add_action( "wpo_set_cart_customer", function ( $cart_customer, $id, $customer_data ) { /* @var WC_Customer $cart_customer */ if ( $cart_customer->meta_exists( 'city' ) ) { $city_code = $cart_customer->get_meta( 'city' ); $cart_customer->set_billing_city( $city_code ); $cart_customer->set_shipping_city( $city_code ); $cart_customer->apply_changes(); } }, 10, 3 ); |