WooCommerce: Read-only Checkout Fields

Especially for B2B sites, it’s likely that customers are managed by the store admin and are not allowed to change their billing/shipping address unless they request to update it.

But even if you’re simply curious, there is a way to turn each checkout field into read-only inputs. In this way, the saved billing and shipping address will load, and the logged in customer won’t be able to change any data before checkout.

A little note: country and state are dropdowns, and this means adding the “readonly” attribute won’t stop you from changing the selected value. However, if we turn all fields to input type “text”, this problem will go away. And this is why you find two statements in the snippet below; first we turn the field into a text input, and then we make it read-only.


Continue reading WooCommerce: Read-only Checkout Fields

WooCommerce: Set Customer Default Tax Location

The WooCommerce settings allow you to define the default customer tax location (“Calculate tax based on” -> “Shop base address“). In this case, when a guest customer enters the checkout, tax will be calculated based on the store address.

The problem is that this option is unusual – businesses require the “Calculate tax based on” -> “Customer billing address” option in most cases.

So, today, we will be setting the default tax location when “Customer billing address” has been chosen AND the customer is either logged out (so, no billing address is set) or logged in but have no saved address (for example, a brand new customer). Enjoy!

Continue reading WooCommerce: Set Customer Default Tax Location

WooCommerce: Get EU, EU VAT, EEA, SCA Countries

When you deal with conditional payment gateways, or conditional notifications, or conditional content, you may need to use to check the current billing country against an array of countries (in plain English, you may want to know if the customer is based in a specific World area), such as the European Union.

Thankfully, WooCommerce gives us a nice prebuilt function so that we don’t need to create the array of EU countries manually. On top of that, it’s easy to manipulate that array in order to add / remove countries for different uses, such as getting the list of EEA (European Economic Area) countries or SCA (Strong Customer Authentication) countries. In this post, I will give you some shortcuts to “calculate” these arrays, so that you don’t need to bother doing it.

Please note, EU, EEA and SCA countries are constantly changing, so these arrays are updated to the date you see on top of this post. Enjoy!

Continue reading WooCommerce: Get EU, EU VAT, EEA, SCA Countries