Commit e31e52f6052 for woocommerce
commit e31e52f6052ee211931ed40ad2418645870d2b88
Author: Vlad Olaru <vlad.olaru@automattic.com>
Date: Fri Oct 2 15:53:47 2026 +0300
Fix stale classic checkout tax and shipping with hidden fields (#69155)
* fix(checkout): don't require address fields the locale hides
Since #67706 the classic checkout validators skip a field the country
locale marks hidden => true, and since #69139 show_shipping() does
too. address-i18n.js still marked such a field required: it hid the
row and emptied its input but kept the validate-required class.
The checkout script only refreshes the order review after an address
edit when every required address input in that section has a value.
The hidden input is always empty, so after the first load no address
edit refreshed the review. With a hidden postcode and rates that vary
by state, switching the state left the old rate on screen while the
order charged the new one: the review showed $15 and the order took
$18.
Treat a field as required only when the locale does not hide it with
exactly true, the rule the server uses since #68111. 'yes' and 1 keep
the field required.
The tests load address-i18n.js and checkout.js against real jQuery.
They cover the hidden row, the 'yes' and 1 flags, the refresh after a
state change, and an empty visible field that must still hold the
refresh.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* chore(changelog): add entry for the hidden address field refresh fix
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
diff --git a/plugins/woocommerce/changelog/fix-classic-checkout-hidden-required-refresh b/plugins/woocommerce/changelog/fix-classic-checkout-hidden-required-refresh
new file mode 100644
index 00000000000..f2e00a1892a
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-classic-checkout-hidden-required-refresh
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Update the classic checkout totals after an address change when an extension hides a required address field.
diff --git a/plugins/woocommerce/client/legacy/js/frontend/address-i18n.js b/plugins/woocommerce/client/legacy/js/frontend/address-i18n.js
index 61f58d282b2..9dea540c989 100644
--- a/plugins/woocommerce/client/legacy/js/frontend/address-i18n.js
+++ b/plugins/woocommerce/client/legacy/js/frontend/address-i18n.js
@@ -79,9 +79,9 @@ jQuery( function( $ ) {
field.find( '.select2-selection__placeholder' ).text( fieldLocale.label );
}
- // Required.
+ // Required. A field the locale hides is not required, as on the server.
if ( typeof fieldLocale.required !== 'undefined' ) {
- field_is_required( field, fieldLocale.required );
+ field_is_required( field, fieldLocale.required && true !== fieldLocale.hidden );
} else {
field_is_required( field, false );
}