File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -171,6 +171,7 @@ protected static function get_shipping_restrictions() {
171
171
$ data_store = WC_Data_Store::load ( 'shipping-zone ' );
172
172
$ raw_zones = $ data_store ->get_zones ();
173
173
$ zones = array ();
174
+ $ shipping_countries = WC ()->countries ->get_shipping_countries ();
174
175
175
176
$ all_continents = WC ()->countries ->get_continents ();
176
177
$ all_countries = WC ()->countries ->get_countries ();
@@ -181,9 +182,8 @@ protected static function get_shipping_restrictions() {
181
182
if ( ! empty ( $ methods ) ) {
182
183
// Rest of the World has shipping methods, so we can assume we can ship to all shipping countries
183
184
// 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 ) {
187
187
$ zones [ $ country ] = new stdClass (); // If we use an empty array it'll be treated as an array in JSON
188
188
}
189
189
return $ zones ;
@@ -239,6 +239,8 @@ protected static function get_shipping_restrictions() {
239
239
}
240
240
}
241
241
242
+ $ zones = array_intersect_key ( $ zones , $ shipping_countries );
243
+
242
244
return $ zones ;
243
245
}
244
246
You can’t perform that action at this time.
0 commit comments