From 350e703704d36c7a7fb3806539846e96356fbc7b Mon Sep 17 00:00:00 2001 From: Marco Almeida Date: Mon, 27 Feb 2023 14:05:43 +0000 Subject: [PATCH] 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 --- plugins/woocommerce/includes/class-wc-cart.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/woocommerce/includes/class-wc-cart.php b/plugins/woocommerce/includes/class-wc-cart.php index 84410f9c505..7cad0c28a0e 100644 --- a/plugins/woocommerce/includes/class-wc-cart.php +++ b/plugins/woocommerce/includes/class-wc-cart.php @@ -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; } }