Skip to content

Commit 907c109

Browse files
authored
Merge pull request #50 from saucal/hotfix/shipping-zones-misscofig
Only allow addresses within the shipping countries
2 parents b556e0d + 12823d8 commit 907c109

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

includes/class-wc-amazon-payments-advanced-api.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ protected static function get_shipping_restrictions() {
171171
$data_store = WC_Data_Store::load( 'shipping-zone' );
172172
$raw_zones = $data_store->get_zones();
173173
$zones = array();
174+
$shipping_countries = WC()->countries->get_shipping_countries();
174175

175176
$all_continents = WC()->countries->get_continents();
176177
$all_countries = WC()->countries->get_countries();
@@ -181,9 +182,8 @@ protected static function get_shipping_restrictions() {
181182
if ( ! empty( $methods ) ) {
182183
// Rest of the World has shipping methods, so we can assume we can ship to all shipping countries
183184
// Skip the whole thing
184-
$countries = WC()->countries->get_shipping_countries();
185-
if ( count( $countries ) !== count( $all_countries ) ) {
186-
foreach ( $countries as $country => $name ) {
185+
if ( count( $shipping_countries ) !== count( $all_countries ) ) {
186+
foreach ( $shipping_countries as $country => $name ) {
187187
$zones[ $country ] = new stdClass(); // If we use an empty array it'll be treated as an array in JSON
188188
}
189189
return $zones;
@@ -239,6 +239,8 @@ protected static function get_shipping_restrictions() {
239239
}
240240
}
241241

242+
$zones = array_intersect_key( $zones, $shipping_countries );
243+
242244
return $zones;
243245
}
244246

0 commit comments

Comments
 (0)