Module LivraisonParSecteurs : On finalise le montant mini du panier nécessaire

This commit is contained in:
2021-02-25 18:04:33 +01:00
parent 4780bf1ff6
commit a077697e70
5 changed files with 33 additions and 13 deletions

View File

@@ -32,6 +32,7 @@ class LivraisonParSecteurs extends AbstractDeliveryModule
const FORMAT_DATES = 'd/m/Y';
const FORMAT_HEURES = 'H:i';
const FORMAT_DATE_COMPLETE = 'Y-m-d H:i:s';
const SECTEUR_ACTIF = 1;
/**
@@ -67,16 +68,21 @@ class LivraisonParSecteurs extends AbstractDeliveryModule
// Condition 1 : le client doit être situé dans un secteur couvert par la livraison à domicile.
if (null !== $areaId = LpsAreaCityQuery::create()->filterByZipcode($zipcode)->findOne($con))
{
$area = LpsAreaQuery::create()->findOneById($areaId);
// Condition 2 : il doit avoir atteint le minimum de commande.
$montantPanier = $this->getRequest()->getSession()->getSessionCart($this->getDispatcher())->getTaxedAmount($country);
$montantMinimum = LpsAreaQuery::create()->findOneById($areaId)->getMinimumAmount();
// Condition 2 : le secteur doit être actif à date.
if ($area->getActive() === self::SECTEUR_ACTIF)
{
// Condition 3 : le panier doit avoir atteint le minimum de commande pour ce secteur.
$montantPanier = $this->getRequest()->getSession()->getSessionCart($this->getDispatcher())->getTaxedAmount($country);
$montantMinimum = $area->getMinimumAmount();
if ($montantPanier >= $montantMinimum)
$isValid = true;
if ($montantPanier >= $montantMinimum)
$isValid = true;
}
}
}
$isValid = true;
return $isValid;
}