Skip to content
Advertisement

Show or hide checkout postcode field based on chosen city in WooCommerce

In Woocommerce, I am trying to hide the checkout postcode field if a specific city field is selected. I found a working code that hides the billing phone if company field is empty:

JavaScript

I don’t know how to alter this code to make the required postcode field to be hidden when a specific billing city is selected. Any help is appreciated.

Advertisement

Answer

It’s a bit much more complicated and you will need to define the city in the last function.

The following code handles multiple necessary tasks to show / hide the postcode field based on a specific defined selected city:

JavaScript

Code goes in functions.php file of your active child theme (or active theme). Tested and works.

Some related answers:


Hidding billing and shipping postcode on load:

Replace:

JavaScript

by:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement