/** * Get all zones where the address is included in. * * @param AddressInterface $address Address * * @return bool Zones where address is contained */ public function getZonesFromAddress(AddressInterface $address) { return $this->zoneRepository->getActiveZones()->filter(function (ZoneInterface $zone) use($address) { return $this->zoneMatcher->isAddressContainedInZone($address, $zone); }); }
/** * Given ShippingRange zones are satisfied by a cart, * * @param CartInterface $cart Cart * @param ShippingRangeInterface $shippingRange Carrier Range * * @return boolean ShippingRange is satisfied by cart */ private function isShippingRangeZonesSatisfiedByCart(CartInterface $cart, ShippingRangeInterface $shippingRange) { $deliveryAddress = $cart->getDeliveryAddress(); $shippingRange->getToZone()->getName(); return $deliveryAddress === null || $this->zoneMatcher->isAddressContainedInZone($deliveryAddress, $shippingRange->getToZone()); }