From 1f68218e4cae817c318cf3fb51900857a7d8d215 Mon Sep 17 00:00:00 2001 From: TheCoreDev Date: Thu, 25 Mar 2021 21:19:54 +0100 Subject: [PATCH] Correction d'un bogue dans le module MondialRelay 1.0.7 --- local/modules/MondialRelay/Config/module.xml | 2 +- .../EventListeners/DeliveryListener.php | 26 +++++++++-------- .../MondialRelay/Loop/DeliveryPrice.php | 12 +++++--- local/modules/MondialRelay/MondialRelay.php | 28 ++++++++++++++++++- 4 files changed, 51 insertions(+), 17 deletions(-) diff --git a/local/modules/MondialRelay/Config/module.xml b/local/modules/MondialRelay/Config/module.xml index 51cb3d5d..21a86e95 100644 --- a/local/modules/MondialRelay/Config/module.xml +++ b/local/modules/MondialRelay/Config/module.xml @@ -13,7 +13,7 @@ en_US fr_FR - 1.0.5 + 1.0.7 Franck Allimant CQFDev diff --git a/local/modules/MondialRelay/EventListeners/DeliveryListener.php b/local/modules/MondialRelay/EventListeners/DeliveryListener.php index cfa3e0a1..a3e26ab6 100644 --- a/local/modules/MondialRelay/EventListeners/DeliveryListener.php +++ b/local/modules/MondialRelay/EventListeners/DeliveryListener.php @@ -57,6 +57,10 @@ class DeliveryListener extends BaseAction implements EventSubscriberInterface $this->requestStack = $requestStack; } + /** + * @return ApiClient + * @throws \SoapFault + */ protected function getWebServiceClient() { return new ApiClient( @@ -136,19 +140,19 @@ class DeliveryListener extends BaseAction implements EventSubscriberInterface $countryHasRelay = true; break; } - } - // If the area delivery type matches the selected one, or if no zone is selected - if (null === $selectedDeliveryType || $zoneDeliveryType === $selectedDeliveryType) { - // Check if we have a price slice - if (null !== $deliveryPrice = MondialRelayDeliveryPriceQuery::create() - ->filterByAreaId($area->getAreaId()) - ->filterByMaxWeight($weight, Criteria::GREATER_EQUAL) - ->orderByMaxWeight(Criteria::ASC) - ->findOne()) { - $price = min($price, $deliveryPrice->getPriceWithTax()); + // If the area delivery type matches the selected one, or if no zone is selected + if (null === $selectedDeliveryType || $zoneDeliveryType === $selectedDeliveryType) { + // Check if we have a price slice + if (null !== $deliveryPrice = MondialRelayDeliveryPriceQuery::create() + ->filterByAreaId($area->getAreaId()) + ->filterByMaxWeight($weight, Criteria::GREATER_EQUAL) + ->orderByMaxWeight(Criteria::ASC) + ->findOne()) { + $price = min($price, $deliveryPrice->getPriceWithTax()); - $deliveryDelay = $zoneConfig->getDeliveryTime(); + $deliveryDelay = $zoneConfig->getDeliveryTime(); + } } } } diff --git a/local/modules/MondialRelay/Loop/DeliveryPrice.php b/local/modules/MondialRelay/Loop/DeliveryPrice.php index 72b28e47..04e2d7a4 100644 --- a/local/modules/MondialRelay/Loop/DeliveryPrice.php +++ b/local/modules/MondialRelay/Loop/DeliveryPrice.php @@ -73,11 +73,15 @@ class DeliveryPrice extends BaseLoop implements ArraySearchLoopInterface $results = []; if (null !== $country = CountryQuery::create()->findPk($this->getCountryId())) { - if (null !== $stateId = $this->getStateId()) { - $state = StateQuery::create()->findPk($this->$stateId()); - } else { - $state = null; + if ($country->getHasStates()) { + if (null !== $stateId = $this->getStateId()) { + $state = StateQuery::create()->findPk($this->$stateId()); + } else { + $state = null; + } } + else + $state = null; $mode = $this->getMode(); diff --git a/local/modules/MondialRelay/MondialRelay.php b/local/modules/MondialRelay/MondialRelay.php index 8e621df1..a80aba35 100644 --- a/local/modules/MondialRelay/MondialRelay.php +++ b/local/modules/MondialRelay/MondialRelay.php @@ -14,6 +14,7 @@ use MondialRelay\Model\MondialRelayDeliveryInsurance; use MondialRelay\Model\MondialRelayDeliveryPrice; use MondialRelay\Model\MondialRelayDeliveryPriceQuery; use MondialRelay\Model\MondialRelayZoneConfiguration; +use Payzen\Model\Thelia\Model\ModuleConfigQuery; use Propel\Runtime\Connection\ConnectionInterface; use Thelia\Core\Translation\Translator; use Thelia\Exception\TheliaProcessException; @@ -29,6 +30,7 @@ use Thelia\Model\Lang; use Thelia\Model\LangQuery; use Thelia\Model\Message; use Thelia\Model\MessageQuery; +use Thelia\Model\ModuleConfig; use Thelia\Model\ModuleImageQuery; use Thelia\Model\OrderPostage; use Thelia\Module\AbstractDeliveryModule; @@ -101,7 +103,7 @@ class MondialRelay extends AbstractDeliveryModule self::setConfigValue(self::CODE_ENSEIGNE, "BDTEST13"); self::setConfigValue(self::PRIVATE_KEY, "PrivateK"); self::setConfigValue(self::WEBSERVICE_URL, "https://api.mondialrelay.com/Web_Services.asmx?WSDL"); - self::setConfigValue(self::GOOGLE_MAPS_API_KEY, "AIzaSyBY_RCM1zkJ0-Df1XMTq3fDzypFC95ZNFE"); + self::setConfigValue(self::GOOGLE_MAPS_API_KEY, "get_your_own_api_key"); self::setConfigValue(self::ALLOW_HOME_DELIVERY, true); self::setConfigValue(self::ALLOW_RELAY_DELIVERY, true); self::setConfigValue(self::ALLOW_INSURANCE, true); @@ -205,4 +207,28 @@ class MondialRelay extends AbstractDeliveryModule } } } + + /** + * @param ConnectionInterface|null $con + * @param bool $deleteModuleData + * @throws \Propel\Runtime\Exception\PropelException + */ + public function destroy(ConnectionInterface $con = null, $deleteModuleData = false) + { + if ($deleteModuleData) { + // Delete message + MessageQuery::create()->filterByName(self::TRACKING_MESSAGE_NAME)->delete($con); + + // Delete module config data + ModuleConfigQuery::create()->filterByModuleId(self::getModuleId())->delete($con); + + // Delete module tables. + if (null !== $con) { + $database = new Database($con); + $database->insertSql(null, [__DIR__ . '/Config/drop.sql']); + } + } + + parent::destroy($con, $deleteModuleData); + } }