Ajout dans la facture du détail de livraison, pour PointRetrait et ClickAndCollect
This commit is contained in:
52
local/modules/ClickAndCollect/Hook/PdfHook.php
Normal file
52
local/modules/ClickAndCollect/Hook/PdfHook.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace ClickAndCollect\Hook;
|
||||
|
||||
use ClickAndCollect\ClickAndCollect;
|
||||
use PlanificationLivraison\Model\OrderDeliveryScheduleQuery;
|
||||
use PlanificationLivraison\PlanificationLivraison;
|
||||
use PointRetrait\Model\PdrPlacesQuery;
|
||||
use Thelia\Core\Event\Hook\HookRenderEvent;
|
||||
use Thelia\Core\Hook\BaseHook;
|
||||
use Thelia\Exception\TheliaProcessException;
|
||||
use Thelia\Model\OrderQuery;
|
||||
|
||||
|
||||
class PdfHook extends BaseHook
|
||||
{
|
||||
public function displayDeliveryDateWithinPdf(HookRenderEvent $event)
|
||||
{
|
||||
$orderId = $event->getArgument('order');
|
||||
$moduleId = OrderQuery::create()->findOneById($orderId)->getDeliveryModuleId();
|
||||
|
||||
if ((null !== $orderId) && $moduleId === ClickAndCollect::getModuleId()) {
|
||||
|
||||
$order = OrderDeliveryScheduleQuery::create()->findOneByOrderId($orderId);
|
||||
if (null !== $order) {
|
||||
$selectedDay = $order->getDueDeliveryTimeStart(PlanificationLivraison::FORMAT_DATES);
|
||||
$beginTime = $order->getDueDeliveryTimeStart(PlanificationLivraison::FORMAT_HEURE);
|
||||
$endTime = $order->getDueDeliveryTimeEnd(PlanificationLivraison::FORMAT_HEURE);
|
||||
$placeID = $order->getDeliveryPlaceId();
|
||||
$place = PdrPlacesQuery::create()->findOneById($placeID);
|
||||
|
||||
if ((null !== $selectedDay) && (null !== $beginTime) && (null !== $endTime)) {
|
||||
$event->add(
|
||||
$this->render(
|
||||
'delivery-address.html', [
|
||||
'day' => $selectedDay,
|
||||
'begin_time' => $beginTime,
|
||||
'end_time' => $endTime,
|
||||
'title' => $place->getTitle(),
|
||||
'address1' => $place->getAddress1(),
|
||||
'address2' => $place->getAddress2(),
|
||||
'zipcode' => $place->getZipcode(),
|
||||
'city' => $place->getCity()
|
||||
])
|
||||
);
|
||||
} else
|
||||
throw new TheliaProcessException("ClickAndCollect : Impossible de récupérer les données");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user