although it’s true that you can search on google, that’s probably why you’re here in the first place. The plugins mentioned are alternatives, but if you still wanna do it, here’s how to turn the city field into a dropdown:
/**
* Change the checkout city field to a dropdown field.
*/
function jeroen_sormani_change_city_to_dropdown( $fields ) {
$city_args = wp_parse_args( array(
'type' => 'select',
'options' => array(
'city1' => 'name city 1',
'city2' => 'name city 2',
'city3' => 'name city 3',
),
), $fields['shipping']['shipping_city'] );
$fields['shipping']['shipping_city'] = $city_args;
$fields['billing']['billing_city'] = $city_args; // Also change for billing field
return $fields;
}
add_filter( 'woocommerce_checkout_fields', 'jeroen_sormani_change_city_to_dropdown' );
ps: I use this code myself, but i claim no ownership over it as i did not write it.
Related Posts:
- how to use wc_create_order with subscription product
- Is it possible to add custom fields to a WooCommerce attribute term? [closed]
- Add custom variable to cart content [closed]
- Woocommerce My Account Endpoint – how to get ID parameter from URL?
- Default woocommerce placeholder image
- How to add Woocomrce cart page shipping calculator to my country state list
- Custom Woocommerce image size [closed]
- Button to update order status Woocommerce with WC Marketplace
- WooCommerce: display text instead of raw checkbox value email
- How we can edit variations on cart page? [closed]
- new WC_Order(); Coming Back Empty
- Is there any way to find which action/hook is fired?
- WooCommerce single products images doesn’t zoom on hover and doesn’t change clicking on gallery
- Disabling the free shipping method when the cart has product/s which assigned a certain shipping class [closed]
- woocommerce_email_subject_customer_completed_order
- is_shop, is_home, is_front_page doesn’t work for woocommerce
- Order list woocommerce Orders based on meta for custom status
- How to add a greeting message upon logging into WordPress for certain user role
- Modify some CSS with functions if (function_exists
- Limit total quantity of products in WooCommerce group product
- WooCommerce hide unexisting variations
- How can I change the functionality of breadcrumbs?
- Variation name in $product->get_name()
- WordPress keeps moving my widgets to other widget areas
- How do I group product variations on cart page (Woocommerce)?
- How do I add an extra field to comment form above the submit button?
- woocommerce email template detect email recipient
- how to remove or disable woocommerce order review in checkout page?
- WordPress and WooCommerce – How many products are too many? [closed]
- Is it safe to have 2 mysql users?
- WooCommerce – Add product with image via REST API
- How to get woocommerce selected variation from order object
- JWT on Woocommerce cannot work with “Customer” role user
- Woocommerce – Add HTML around Product description [closed]
- relocate woocommerce notices/messages on Cart page
- Adjust Price Display for Variable Product in Woocommerce [closed]
- Unable to pull in custom product attribute in shortcode [closed]
- Woocommerce emails from gmail not being sent
- lost password link not working for my site
- How to give each category name its own ACF background color?
- How it it possible to disbale all WooCommerce scripts and styles, but keep wc-ajax=get_refreshed_fragments working? [closed]
- Woocommerce cart is not clear after logout
- WooCommerce event works in jQuery but not in JavaScript
- Filter default_content only for products
- Woocommerce : read [max_qty] using backorder
- Is there any way to pro-grammatically create product categories and assign thumbnails in PHP and WooCommerce?
- Remove Visual Editor and P tags from WooCommerce Taxonomy Descriptions [closed]
- Append woocommerce category to product title globally? [closed]
- Custom fields values not being created
- Adding additional text under the price via product page
- Display WooCommerce product category on shop page (on every product)
- Multisite login – registration is duplicated
- WooCommerce variable product can not add to cart using ajax after updating latest version of WooCommerce
- Create a Search Form that only Searches with WooCommerce Sale Products
- Update WooCommerce Sale Price & Date Based On Attribute Value
- One Time Access URL after purchasing subscription
- How to fetch WooCommerce products with 50% discount?
- Anonymous users can not access website
- Add quantity of variations together and show it to parent quantity field Woocommerce
- How to make phone number become whatsapp link in back-end order details woocommerce
- add_post_meta add latest data from meta_value array
- select2 & selectWoo Not Loading Options
- WordPress & Woocommerce variation Price
- Adding country subdomain to an existing website like www.example.com/uk
- Move woocommerce directory
- Hide review form if user has left a comment
- Some html elements displaing in a strange order in WordPress
- Update / refresh mini cart, after custom AJAX add_to_cart event
- Would it be ok if i had only 1 main woocommerce category?
- How to get product variation price in woocommerce_checkout_create_order_line_item hook
- Custom theme woocommerce product detail page template not working
- Increase the download speed of a large number of variations in WooCommerce
- How to add product variations for large number of products in WooCommerce?
- WooCommerce related products load random posts per page
- WooCommerce: Adding a setup fee to certain products
- Removing shipping for one product with coupon
- Woocommerce Languages Files
- How to adjust Related Page Thumb Sizes on single page?
- Adding more than one item to Woocommerce cart
- Woocommerce – get product in category with specific attribute
- Woocommerce make appear when items added to cart
- How to edit the header banner in the search page in woocommerce?
- How can I display one product using WooCommerce
- How do I change the woocommerce product gallery to show all thumbnails instead of three at a time in a carousel?
- How to add a menu page for options in wordpress for user that has the role of vendor?
- Testimonials/Reviews for Products
- add custom menu in woocommerce dashboard [closed]
- Turkish Character Problem on mailing
- WooCommerce: Order Details Table > Add Product Meta
- Override function
- How to disable schema from Wocommerce? [closed]
- Updating order meta to have a meta entry from an item in the order
- registration_errors not working
- How to dublicate WC Product title to shortdescription field? [closed]
- Translate Woocommerce tab
- Woocommerce -> gallery images per variation without a plugin? [closed]
- Why is my WordPress admin not working
- Create bookings after subscription renewal
- Change variants URL
- Use a woocommerce hook to create a table and populate it with a query