Digital Wallets – filter_checkout_fields priority too low
-
Hi!
When digital wallets (Apple Pay, Google Pay) are used, the plugin sets
billing_stateandshipping_statetorequired: false. Because the filter runs at priority 10, any other filter at priority 10 (which is often the case) can run after it and set these fields back to required: true, causing validation failures during checkout.Because of that digital wallet checkouts fail validation when state fields are required and users are from countries where state does not exists.
The filter should run at a high priority (e.g., 999) to ensure it executes after other filters and its changes are not overridden.
-
This topic was modified 2 months, 2 weeks ago by
Nino Mihovilic.
-
This topic was modified 2 months, 2 weeks ago by
-
Hi there!
Thanks for the detailed analysis that makes sense, and we appreciate you calling out the filter priority behavior.
To better understand what’s overriding this on your sites, could you let us know which other plugin, theme, or custom code is adding a filter to the same checkout fields?
The reason we’re asking is that we’re not seeing this behavior on our test sites, so identifying what’s running after our filter would help us confirm whether this is a compatibility issue or something we should adjust on our side.
Once we have that information, we can take a closer look and advise on the best next step.
Hi!
Sorry, now I’ve noticed that I wrongly explained above. In the plugin code
billing_stateandshipping_statestate are NOT set torequired false, but instead onlybilling_company&shipping_companyare set torequired false.The issue happens if you are using a Digital Wallet in a country where state is not mandatory (not set in Apple Wallet for example), WP returns validation errors that the state is a required field which breaks the purchase flow.
Hi there!
Thank you for sharing the details about the issue. To assist you further, could you please share the site URL where you are using the digital wallet? We would like to replicate the issue on your site. Currently we are not able to replicate that issue.
Also, please share the System Status Report, which you can find via WooCommerce → Status. You can use https://pastebin.com/ or https://gist.github.com/ and share the link to your paste in reply here.
Once we are able to replicate the issue on your site, we will be happy to forward it to our developer.
Hi!
Here is the link https://ninomihovilictestingo.wpcomstaging.com.
System report -> https://pastebin.com/YDGJbbpM
It’s important to not have State set on the Apple Pay account. This is what causes the issue.
Hi @ninomiho,
Thanks for sharing the system status report and the staging site link, I have reviewed the report and everything looks good from an environment and configuration standpoint, which helps rule out any obvious setup issues.
I also tried testing on the staging site. At the moment, I am not seeing the Apple Pay option available at checkout. I do see Google Pay, however clicking it does not initiate the Google Pay digital wallet flow or open the payment screen on my end, so I was not able to fully reproduce the behavior yet.
To help narrow this down further, could you please clarify whether this issue only occurs with Apple Pay, or if you are also seeing the same validation failure with Google Pay when the state field is not provided. Confirming that will help us understand whether this is wallet specific or affects digital wallets more generally, and will make it easier to raise this with the developers alongside a clear reproduction path.
Once I have that confirmation, I can continue testing and move this forward internally.
Hi!
I don’t use Google Pay, so I’m not sure if it works correctly in production, but while testing, it worked. It worked because I can see that Google populates the fields with random data, which has the State field set.
Hi there!
Thank you for providing more information that’s very helpful.
I’ve internally escalated this issue to our development team for further review. I’ll be sure to update you as soon as I hear back from them.
Thanks again for taking the time to share these details.
Hi @ninomiho,
Thanks again for your patience while we reviewed this internally.
We’ve taken a closer look, and it appears the issue stems from a misunderstanding of how WooCommerce handles locale‑based address requirements.
WooCommerce loads its address rules from the core locale database. This means the checkout dynamically adjusts based on the customer’s selected country:
- Countries like the US require a state.
- Countries like Ireland do not.
- Wallets generally follow similar logic, though they don’t use the exact same database.
Over the years there have been a few mismatches between Apple Pay and WooCommerce for specific countries, and those were corrected as they surfaced.
The
woocommerce_checkout_fieldsfilter on the other hand, is intentionally set at the default priority of 10. This is expected behavior.
If a plugin needs to override WooCommerce’s defaults, it should adjust its own filter priority, either earlier or later, depending on what it needs to achieve. WooCommerce itself must remain at the default priority; otherwise, it wouldn’t be the default.To help us pinpoint the mismatch, could you confirm:
- Which country is being used when the issue occurs?
- Which wallet (Apple Pay, Google Pay) and which gateway is processing it?
Once we have that, we can check whether this is a country‑specific mismatch between the wallet’s data and WooCommerce’s locale rules.
Hi!
Which country is being used when the issue occurs?
I’m using Croatia.
Which wallet (Apple Pay, Google Pay) and which gateway is processing it?
Apple Pay, WooCommerce Square
Hi there!
Thank you for the udpate. It’s possible that there is a mismatch between what Apple has for Croatia and what WooCommerce expects.In WooCommerce, the State field for Croatia is currently:
- Required
- Visible (shown as a dropdown with 21 Croatian counties)
- Using the default label “State / County”
If you need to make the state field optional for Croatia, you can add a locale override entry for
HRin the locale array withrequiredset accordingly.For testing purposes, could you please install the Code Snippets plugin and add the following snippet?
/**
* Override WooCommerce locale settings for Croatia (HR)
* Make state field optional instead of required
*/
add_filter( 'woocommerce_get_country_locale', function( $locale ) {
$locale['HR'] = array(
'state' => array(
'required' => false,
'label' => __( 'County', 'woocommerce' ), // Optional: customize label
),
);
return $locale;
}, 10, 1 );Let us know if that work for you.
Hi!
Yes, it works with the snippet, but I don’t think this is a long-term solution. I would need to figure out which countries don’t use “state” and then add those to the snippet. This will only fix the issue on my site, while others will still have the same problem with the your plugin. When using WooPayments, it works normally without adding any snippet.
Hi there!
Thanks for the update we completely understand your concern.
You’re absolutely right that using a snippet isn’t an ideal long-term solution, especially since it would require maintaining a list of countries that don’t use a “state” field and would only address the issue on your site. We also appreciate you pointing out that this works as expected when using WooPayments, which is a very helpful comparison.
We’ll share all of this information with our development team so they can review the behavior and investigate a proper fix at the plugin level, rather than relying on a workaround.
In the meantime, thank you for testing the snippet and for clearly explaining the limitations you’re seeing that context is extremely valuable for our developers.
We’ll follow up once we have more information or an update to share.
Before you go, If you’re happy with the support you received today, would you consider leaving us a quick review? It really helps us out: https://ww.wp.xz.cn/support/plugin/woocommerce-square/reviews/#new-post
You must be logged in to reply to this topic.