diff --git a/src/Repository/ZoneRepository.php b/src/Repository/ZoneRepository.php index 04effa9..9bf2ba9 100644 --- a/src/Repository/ZoneRepository.php +++ b/src/Repository/ZoneRepository.php @@ -120,6 +120,20 @@ public function findProductsInZoneRange(Address $address, string $carrierReferen $idCountry = $address->id_country ?: (int)\Configuration::get('PS_COUNTRY_DEFAULT'); $zipCode = $address->postcode; + $query = new DbQuery(); + + $query->select('dp.*'); + $query->from('dpd_product', 'dp'); + $query->where('dp.id_reference = ' . pSql($carrierReference)); + $query->where('dp.active = ' . (int) 1); + $query->where('dp.all_zones = ' . (int) 1); + + $result = $this->db->executeS($query); + + if (!empty($result)) { + return $result; + } + $query = new DbQuery(); $query->select('dp.*'); $query->from('dpd_zone', 'dz'); @@ -129,7 +143,7 @@ public function findProductsInZoneRange(Address $address, string $carrierReferen $query->where('dp.active = ' . (int) 1); $query->where('dzr.id_country = ' . (int)$idCountry); - $query->where('dzr.include_all_zip_codes = 1 OR (dzr.zip_code_from <= \'' . pSQL($zipCode) . '\' AND dzr.zip_code_to >= \'' . pSQL($zipCode) . '\')'); + $query->where('dzr.include_all_zip_codes = 1 OR (dzr.zip_code_from_numeric <= \'' . pSQL($zipCode) . '\' AND dzr.zip_code_to_numeric >= \'' . pSQL($zipCode) . '\')'); $productsIdReferences = $this->db->executeS($query); $result = []; diff --git a/src/Service/ShippingPriceCalculationService.php b/src/Service/ShippingPriceCalculationService.php index fff6b5c..7151814 100644 --- a/src/Service/ShippingPriceCalculationService.php +++ b/src/Service/ShippingPriceCalculationService.php @@ -53,7 +53,10 @@ public function __construct( public function calculate(Cart $cart, \Carrier $carrier, Address $deliveryAddress) { $shippingCosts = 0.0; - //todo debug here why prices are not shown correctly + //todo price rules do not exist if setting is all price rule exist + // if prz all zones = 1 + // check if carrier set to all zones if yes we take price rule of the all_zones + $priceRulesIds = $this->priceRuleRepository->getByCarrierReference( $deliveryAddress, $carrier->id_reference,