Allow removing postcode and state from calculator even if required

Allow removing postcode and state fields from the shipping calculator, if they're not needed for calculation, even if they're required at the checkout.
Fixes #28393
This commit is contained in:
Marco Almeida 2023-02-27 14:05:43 +00:00 committed by barryhughes
parent 0a11d03ce5
commit 350e703704
1 changed files with 2 additions and 2 deletions

View File

@ -1573,10 +1573,10 @@ class WC_Cart extends WC_Legacy_Cart {
return false;
}
$country_fields = WC()->countries->get_address_fields( $country, 'shipping_' );
if ( isset( $country_fields['shipping_state'] ) && $country_fields['shipping_state']['required'] && ! $this->get_customer()->get_shipping_state() ) {
if ( apply_filters( 'woocommerce_shipping_calculator_enable_state', true ) && isset( $country_fields['shipping_state'] ) && $country_fields['shipping_state']['required'] && ! $this->get_customer()->get_shipping_state() ) {
return false;
}
if ( isset( $country_fields['shipping_postcode'] ) && $country_fields['shipping_postcode']['required'] && ! $this->get_customer()->get_shipping_postcode() ) {
if ( apply_filters( 'woocommerce_shipping_calculator_enable_postcode', true ) && isset( $country_fields['shipping_postcode'] ) && $country_fields['shipping_postcode']['required'] && ! $this->get_customer()->get_shipping_postcode() ) {
return false;
}
}