diff --git a/core/lib/Thelia/Config/Resources/routing/front.xml b/core/lib/Thelia/Config/Resources/routing/front.xml
index 4c88f707f..aeff55d7c 100755
--- a/core/lib/Thelia/Config/Resources/routing/front.xml
+++ b/core/lib/Thelia/Config/Resources/routing/front.xml
@@ -63,6 +63,7 @@
Thelia\Controller\Front\DeliveryController::select
+ \d+
diff --git a/core/lib/Thelia/Controller/Front/DeliveryController.php b/core/lib/Thelia/Controller/Front/DeliveryController.php
index abb2e7fae..ef84be6ab 100644
--- a/core/lib/Thelia/Controller/Front/DeliveryController.php
+++ b/core/lib/Thelia/Controller/Front/DeliveryController.php
@@ -33,7 +33,7 @@ use Thelia\Tools\URL;
*/
class DeliveryController extends BaseFrontController
{
- public function select()
+ public function select($delivery_id)
{
if ($this->getSecurityContext()->hasCustomerUser() === false) {
$this->redirect(URL::getInstance()->getIndexPage());
@@ -41,15 +41,16 @@ class DeliveryController extends BaseFrontController
$request = $this->getRequest();
- $deliveryId = $request->query->get("delivery_id");
+ $deliveryModule = ModuleQuery::create()
+ ->filterById($delivery_id)
+ ->filterByActivate(1)
+ ->findOne()
+ ;
- if($deliveryId)
- {
- $deliveryModule = ModuleQuery::create()->findPk($deliveryId);
-
- if ($deliveryModule) {
- $request->getSession()->setDelivery($deliveryId);
- }
+ if ($deliveryModule) {
+ $request->getSession()->setDelivery($delivery_id);
+ } else {
+ $this->pageNotFound();
}
}
}
\ No newline at end of file
diff --git a/core/lib/Thelia/Core/Template/Loop/Delivery.php b/core/lib/Thelia/Core/Template/Loop/Delivery.php
index 6a634d2bf..7ef46eedc 100644
--- a/core/lib/Thelia/Core/Template/Loop/Delivery.php
+++ b/core/lib/Thelia/Core/Template/Loop/Delivery.php
@@ -60,6 +60,9 @@ class Delivery extends BaseSpecificModule
$loopResultRow = new LoopResultRow($loopResult, $deliveryModule, $this->versionable, $this->timestampable, $this->countable);
$moduleReflection = new \ReflectionClass($deliveryModule->getFullNamespace());
+ if($moduleReflection->isSubclassOf("Thelia\Module\DeliveryModuleInterface") === false) {
+ throw new \RuntimeException(sprintf("delivery module %s is not a Thelia\Module\DeliveryModuleInterface", $deliveryModule->getCode()));
+ }
$moduleInstance = $moduleReflection->newInstance();
$moduleInstance->setRequest($this->request);
diff --git a/templates/default/delivery_list.html b/templates/default/delivery_list.html
index c3fbcd0f3..2ea3cc166 100644
--- a/templates/default/delivery_list.html
+++ b/templates/default/delivery_list.html
@@ -2,8 +2,13 @@
{loop type="delivery" name="delivery.list"}
- - id : #ID
- - prix : #PRICE
+ -
+
+ - id : {#ID}
+ - prix : {#PRICE}
+ - Choisir : Choisir
+
+
{/loop}