LivraisonParSecteurs : On avance sur la partie front...

This commit is contained in:
2021-02-17 20:31:11 +01:00
parent c3af0a66ba
commit 37220bfef9
41 changed files with 2522 additions and 25 deletions

View File

@@ -0,0 +1,46 @@
<?php
namespace LivraisonParSecteurs\Hook;
use LivraisonParSecteurs\LivraisonParSecteurs;
use LivraisonParSecteurs\Model\Base\LpsAreaCityQuery;
use Propel\Runtime\Exception\PropelException as PropelException;
use Propel\Runtime\Propel;
use Thelia\Core\Event\Hook\HookRenderEvent;
use Thelia\Core\Hook\BaseHook;
use Thelia\Core\Translation\Translator;
use Thelia\Model\AddressQuery;
use Thelia\Module\Exception\DeliveryException;
class FrontHook extends BaseHook
{
public function onOrderDeliveryExtra(HookRenderEvent $event)
{
$con = Propel::getConnection();
$addressId = $this->getRequest()->getSession()->getOrder()->getChoosenDeliveryAddress();
$zipcode = AddressQuery::create()->filterById($addressId)->findOne($con)->getZipcode();
try {
$areaId = LpsAreaCityQuery::create()->findOneByZipcode($zipcode)->getIdArea();
}
catch (PropelException $e) {
throw new DeliveryException(
Translator::getInstance()->trans("This module cannot be used on the current cart."));
}
$event->add(
$this->render(
'order-delivery-extra.html',
[
'module_id' => LivraisonParSecteurs::getModuleId(),
'address_id' => $addressId,
'area_id' => $areaId
]
)
);
}
}