Skip to content

Commit

Permalink
PES-2071: native wc shipping methods modal carriers - continents supp…
Browse files Browse the repository at this point in the history
…ort (#553)

Co-authored-by: FJiskra <filip.jiskra@packeta.com>
  • Loading branch information
jan-potuznik-z and FJiskra committed May 31, 2024
1 parent 87cec9e commit 64196f9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Packetery/Module/ShippingZoneRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ public function getCountryCodesForShippingRate( string $rateId ): array {
$countries = [];
$zoneLocations = $this->getLocationsForShippingRate( $rateId );
if ( ! empty( $zoneLocations ) ) {
$continents = WC()->countries->get_continents();

/**
* Zone location.
*
Expand All @@ -103,6 +105,12 @@ public function getCountryCodesForShippingRate( string $rateId ): array {
if ( 'country' === $zoneLocation->type ) {
$countries[] = strtolower( $zoneLocation->code );
}

if ( 'continent' === $zoneLocation->type && isset( $continents[ $zoneLocation->code ]['countries'] ) ) {
foreach ( $continents[ $zoneLocation->code ]['countries'] as $countryCode ) {
$countries[] = strtolower( $countryCode );
}
}
}
}

Expand Down

0 comments on commit 64196f9

Please sign in to comment.