From 107720dc08b50fba534cf9735c06fb82784526b9 Mon Sep 17 00:00:00 2001 From: Claudio Sanches Date: Fri, 10 Jan 2020 17:05:28 -0300 Subject: [PATCH 1/2] Make is_package_shippable less strict --- includes/class-wc-shipping.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/includes/class-wc-shipping.php b/includes/class-wc-shipping.php index de5cb859603..ef2bfe08ed3 100644 --- a/includes/class-wc-shipping.php +++ b/includes/class-wc-shipping.php @@ -294,12 +294,7 @@ class WC_Shipping { } $states = WC()->countries->get_states( $country ); - if ( is_array( $states ) && ! isset( $states[ $package['destination']['state'] ] ) ) { - return false; - } - - $postcode = wc_format_postcode( $package['destination']['postcode'], $country ); - if ( ! WC_Validation::is_postcode( $postcode, $country ) ) { + if ( is_array( $states ) && ! empty( $states ) && ! isset( $states[ $package['destination']['state'] ] ) ) { return false; } From f253c8709685ba3f61cd56787e6d005bf5e84a42 Mon Sep 17 00:00:00 2001 From: Claudio Sanches Date: Fri, 10 Jan 2020 17:14:44 -0300 Subject: [PATCH 2/2] Fixed unit tests --- tests/unit-tests/shipping/shipping.php | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/tests/unit-tests/shipping/shipping.php b/tests/unit-tests/shipping/shipping.php index f922899afd7..87c2d6b7569 100644 --- a/tests/unit-tests/shipping/shipping.php +++ b/tests/unit-tests/shipping/shipping.php @@ -60,19 +60,6 @@ class WC_Tests_Shipping extends WC_Unit_Test_Case { ); $this->assertFalse( $result ); - // Failure for invalid postcode. - $result = $shipping->is_package_shippable( - array( - 'destination' => array( - 'country' => 'US', - 'state' => 'CA', - 'postcode' => 'test', - 'address' => '', - ), - ) - ); - $this->assertFalse( $result ); - // Success for correct address. $result = $shipping->is_package_shippable( array(