Skip to content
Advertisement

Customize addresses fields on WooCommerce My account and Checkout

I’m using the woocommerce_checkout_fields filter to edit the value of woocommerce field labels. It works fine on the checkout page (as you might expect), however I cannot understand why it doesn’t also take effect on the account pages. I thought these fields were still taken form the same place? More specifically, I’m talking about the address fields on the edit-address endpoint on woocommerce account pages?

My code attempt:

JavaScript

Fields doesn’t get customized on My account > Addresses (edit billing or shipping address).

Advertisement

Answer

The hook woocommerce_checkout_fields only allow customizations on checkout page and will not affect the My account “Addresses” section fields.

The following will affect both My account “Addresses” section fields and checkout fields, allowing to make billing and shipping fields customized also on the related my account section.


1) For addresses fields (both billing and shipping) on My account and checkout:

In some cases you need to use this filter for addresses fields and it’s applied to all billing and shipping default fields:

JavaScript

You can use WooCommerce conditional tags is_account_page() and is_checkout() to target my account pages or checkout page…


2) For Billing fields on my account edit-addresses and checkout:

JavaScript

3) For Shipping fields on my account edit-addresses and checkout

JavaScript

4) All (other) fields only on checkout:

JavaScript

5) Also depending on the selected country, you should need to use the filters:

  • woocommerce_country_locale_field_selectors
  • woocommerce_get_country_locale_default

Those are located on WC_Country Class.

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


Related official documentation: Customizing checkout fields using actions and filters

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