Setting a shipping zone for a country opens the way to show or hide a checkout field only for customers from that country. All the necessary functions are included in the PRO version of Flexible Checkout Fields plugin. This is mainly because it supports conditional logic on the Checkout based on shipping methods. In this article I will show all the steps needed to get this feature - and thus benefit from the country-targeted checkout fields.
Customize the WooCommerce Checkout
Flexible Checkout Fields is a plugin for easy customizing the Checkout page. Its field management is also very simple and comes with one click. The Pro version also has the option of using conditional logic. Thanks to this function it is possible to show or hide a checkout field only if a specific condition (or several of them combined) is met.
There are three types of rules to choose from:
- conditional logic based on a product or category
- conditional logic based on checkbox/radio/select field added by the plugin
- and conditional logic based on the shipping method
Hide checkout fields based on shipping method in WooCommerce
by Bartosz Gajewski
At first glance there is no way to set conditional logic based on the selected option in the country field. But in practice we get this functionality by using the shipping method as a rule for showing or hiding the field because shipping methods are assigned to specific locations (like country).
Checkout page field for a specific country
Step One: Set up a separate shipping zone.
- Add new shipping zone.
WooCommerce > Settings > Shipping zones > Add shipping zone
- Set up the shipping zone.
- Enter a name.
- Select the country.
- Add at least one shipping method.
- Configure shipping methods.
- Organize shipping zones.
If the country is in more than one shipping zone - please drag the newly created zone and drop it over the other zone. In this example Poland also belongs to the "Europe" shipping zone. That is why the "Poland" zone should be placed above the "Europe" zone.
Step Two: Configure conditional logic in Flexible Checkout Fields for a specific country.
- Select the tab where you want to set the field with conditional logic (e.g. "Billing").
- Add a new field or select an existing one.
- Select the "Advanced" tab and check the "Enable Shipping Methods Logic" checkbox.
- Leave "Show this field if" turned on and click "Add rule".
- Select the created shipping zone along with the assigned shipping method. Then follow this step for each shipping method assigned to that shipping zone.
As a result - the field modified this way will be now hidden. But it will become visible when the customer selects this particular country in the "Country/Region" field. Also it is possible to apply the opposite criterion - just select the "Hide this field if" option to hide that field from the customer.
PRO TIP - WooCommerce Debug mode
WooCommerce "Debug mode" is a helpful tool which shows at the Checkout if the customer from the selected country actually belongs to the dedicated shipping zone. Remember to turn it off before launching the store.
WooCommerce > Settings > Shipping > Shipping options > Enable debug mode
In conclusion - there are many situations where it may be useful to customize the WooCommerce Checkout that way. Show or hide a country-targeted fields to:
- collect address data of better quality
- place messages and labels in the language of a specific customer
- decide whether the field for a given country will be required or not
- and a lot more!
It is possible to test our plugin in action - our demo is waiting.