LivraisonParSecteur : Rajout de la gestion du minimum de commande
This commit is contained in:
@@ -7,6 +7,7 @@ use LivraisonParSecteurs\Model\LpsAreaCityQuery;
|
||||
use LivraisonParSecteurs\Model\LpsAreaQuery;
|
||||
use Propel\Runtime\Connection\ConnectionInterface;
|
||||
use Propel\Runtime\Propel;
|
||||
use Symfony\Component\Form\FormError;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Install\Database;
|
||||
use Thelia\Model\AddressQuery;
|
||||
@@ -28,6 +29,10 @@ class LivraisonParSecteurs extends AbstractDeliveryModule
|
||||
const LPS_DELIVERY_DATE = 'lps_delivery_date';
|
||||
const LPS_DELIVERY_BEGIN_TIME = 'lps_begin_time';
|
||||
const LPS_DELIVERY_END_TIME = 'lps_end_time';
|
||||
const FORMAT_DATES = 'd/m/Y';
|
||||
const FORMAT_HEURES = 'H:i';
|
||||
const FORMAT_DATE_COMPLETE = 'Y-m-d H:i:s';
|
||||
|
||||
|
||||
/**
|
||||
* @param ConnectionInterface|null $con
|
||||
@@ -59,8 +64,17 @@ class LivraisonParSecteurs extends AbstractDeliveryModule
|
||||
if (!empty($currentAddressId)) {
|
||||
$zipcode = AddressQuery::create()->filterById($currentAddressId)->findOne($con)->getZipcode();
|
||||
|
||||
if (null !== LpsAreaCityQuery::create()->filterByZipcode($zipcode)->findOne($con))
|
||||
$isValid = true;
|
||||
// Condition 1 : le client doit être situé dans un secteur couvert par la livraison à domicile.
|
||||
if (null !== $areaId = LpsAreaCityQuery::create()->filterByZipcode($zipcode)->findOne($con))
|
||||
{
|
||||
|
||||
// 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();
|
||||
|
||||
if ($montantPanier >= $montantMinimum)
|
||||
$isValid = true;
|
||||
}
|
||||
}
|
||||
|
||||
return $isValid;
|
||||
|
||||
Reference in New Issue
Block a user