Merge pull request #25386 from woocommerce/fix/is_package_shippable

Make WC_Shipping::is package shippable less strict
This commit is contained in:
Claudio Sanches 2020-01-14 14:30:17 -03:00 committed by GitHub
commit 4c39f81f12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 19 deletions

View File

@ -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;
}

View File

@ -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(