Fix postcode validation within the legacy cart show_shipping method (#51623)

* Postcode should be compared to empty string to prevent `0` passing.

* Changelog
This commit is contained in:
Mike Jolley 2024-09-27 11:45:33 +01:00 committed by GitHub
parent 536bb4627e
commit 63637c0235
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 1 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
Fix postcode validation within the legacy cart show_shipping method.

View File

@ -1597,7 +1597,7 @@ class WC_Cart extends WC_Legacy_Cart {
*/ */
$postcode_enabled = apply_filters( 'woocommerce_shipping_calculator_enable_postcode', true ); $postcode_enabled = apply_filters( 'woocommerce_shipping_calculator_enable_postcode', true );
$postcode_required = isset( $country_fields['shipping_postcode'] ) && $country_fields['shipping_postcode']['required']; $postcode_required = isset( $country_fields['shipping_postcode'] ) && $country_fields['shipping_postcode']['required'];
if ( $postcode_enabled && $postcode_required && ! $this->get_customer()->get_shipping_postcode() ) { if ( $postcode_enabled && $postcode_required && '' === $this->get_customer()->get_shipping_postcode() ) {
return false; return false;
} }
} }