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\Exception\OrderException;
|
||||
use Thelia\Model\CountryQuery;
|
||||
use Thelia\Model\Module;
|
||||
use Thelia\Module\BaseModule;
|
||||
use Thelia\Module\DeliveryModuleInterface;
|
||||
use Thelia\Module\Exception\DeliveryException;
|
||||
|
||||
/**
|
||||
* Class Delivery
|
||||
@@ -64,11 +62,9 @@ class Delivery extends BaseSpecificModule
|
||||
$country = $this->container->get('thelia.taxEngine')->getDeliveryCountry();
|
||||
}
|
||||
|
||||
/** @var Module $deliveryModule */
|
||||
foreach ($loopResult->getResultDataCollection() as $deliveryModule) {
|
||||
$loopResultRow = new LoopResultRow($deliveryModule);
|
||||
|
||||
/** @var DeliveryModuleInterface $moduleInstance */
|
||||
$moduleInstance = $this->container->get(sprintf('module.%s', $deliveryModule->getCode()));
|
||||
|
||||
if (false === $moduleInstance instanceof DeliveryModuleInterface) {
|
||||
@@ -76,12 +72,17 @@ class Delivery extends BaseSpecificModule
|
||||
}
|
||||
|
||||
try {
|
||||
// Check if module is valid, by calling isValidDelivery(),
|
||||
// or catching a DeliveryException.
|
||||
|
||||
if ($moduleInstance->isValidDelivery($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
|
||||
->set('ID', $deliveryModule->getId())
|
||||
@@ -94,10 +95,6 @@ class Delivery extends BaseSpecificModule
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
} catch (DeliveryException $ex) {
|
||||
// Module is not available
|
||||
}
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user