Skip to content

Commit

Permalink
price rule fix
Browse files Browse the repository at this point in the history
  • Loading branch information
GytisZum committed Feb 29, 2024
1 parent 9727f74 commit 82f9354
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
16 changes: 15 additions & 1 deletion src/Repository/ZoneRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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 = [];
Expand Down
5 changes: 4 additions & 1 deletion src/Service/ShippingPriceCalculationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 82f9354

Please sign in to comment.