Restored previous version
This commit is contained in:
@@ -27,10 +27,8 @@ use Thelia\Core\Template\Element\LoopResultRow;
|
|||||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||||
use Thelia\Exception\OrderException;
|
use Thelia\Exception\OrderException;
|
||||||
use Thelia\Model\CountryQuery;
|
use Thelia\Model\CountryQuery;
|
||||||
use Thelia\Model\Module;
|
|
||||||
use Thelia\Module\BaseModule;
|
use Thelia\Module\BaseModule;
|
||||||
use Thelia\Module\DeliveryModuleInterface;
|
use Thelia\Module\DeliveryModuleInterface;
|
||||||
use Thelia\Module\Exception\DeliveryException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Delivery
|
* Class Delivery
|
||||||
@@ -64,11 +62,9 @@ class Delivery extends BaseSpecificModule
|
|||||||
$country = $this->container->get('thelia.taxEngine')->getDeliveryCountry();
|
$country = $this->container->get('thelia.taxEngine')->getDeliveryCountry();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var Module $deliveryModule */
|
|
||||||
foreach ($loopResult->getResultDataCollection() as $deliveryModule) {
|
foreach ($loopResult->getResultDataCollection() as $deliveryModule) {
|
||||||
$loopResultRow = new LoopResultRow($deliveryModule);
|
$loopResultRow = new LoopResultRow($deliveryModule);
|
||||||
|
|
||||||
/** @var DeliveryModuleInterface $moduleInstance */
|
|
||||||
$moduleInstance = $this->container->get(sprintf('module.%s', $deliveryModule->getCode()));
|
$moduleInstance = $this->container->get(sprintf('module.%s', $deliveryModule->getCode()));
|
||||||
|
|
||||||
if (false === $moduleInstance instanceof DeliveryModuleInterface) {
|
if (false === $moduleInstance instanceof DeliveryModuleInterface) {
|
||||||
@@ -76,12 +72,17 @@ class Delivery extends BaseSpecificModule
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Check if module is valid, by calling isValidDelivery(),
|
|
||||||
// or catching a DeliveryException.
|
|
||||||
|
|
||||||
if ($moduleInstance->isValidDelivery($country)) {
|
|
||||||
|
|
||||||
$postage = $moduleInstance->getPostage($country);
|
$postage = $moduleInstance->getPostage($country);
|
||||||
|
} catch (OrderException $e) {
|
||||||
|
switch ($e->getCode()) {
|
||||||
|
case OrderException::DELIVERY_MODULE_UNAVAILABLE:
|
||||||
|
/* do not show this delivery module */
|
||||||
|
continue(2);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$loopResultRow
|
$loopResultRow
|
||||||
->set('ID', $deliveryModule->getId())
|
->set('ID', $deliveryModule->getId())
|
||||||
@@ -94,10 +95,6 @@ class Delivery extends BaseSpecificModule
|
|||||||
|
|
||||||
$loopResult->addRow($loopResultRow);
|
$loopResult->addRow($loopResultRow);
|
||||||
}
|
}
|
||||||
} catch (DeliveryException $ex) {
|
|
||||||
// Module is not available
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $loopResult;
|
return $loopResult;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user