Check for state and postcode fields only if required
We were doing state and postcode even for countries where its not required, but unfortunately as an unintended effect we were ending up not checking shipping requirements if this was not met.
This commit is contained in:
parent
6eb65cb40c
commit
7f2b322085
|
@ -1528,7 +1528,15 @@ class WC_Cart extends WC_Legacy_Cart {
|
|||
}
|
||||
|
||||
if ( 'yes' === get_option( 'woocommerce_shipping_cost_requires_address' ) ) {
|
||||
if ( ! $this->get_customer()->get_shipping_country() || ! $this->get_customer()->get_shipping_state() || ! $this->get_customer()->get_shipping_postcode() ) {
|
||||
$country = $this->get_customer()->get_shipping_country();
|
||||
if ( ! $country ) {
|
||||
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() ) {
|
||||
return false;
|
||||
}
|
||||
if ( isset( $country_fields['shipping_postcode'] ) && $country_fields['shipping_postcode']['required'] && ! $this->get_customer()->get_shipping_postcode() ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue