Encore des modifs sur module DHL
This commit is contained in:
@@ -17,8 +17,11 @@ use Thelia\Model\CountryArea;
|
||||
use Thelia\Model\CountryQuery;
|
||||
use Thelia\Model\MessageQuery;
|
||||
use Thelia\Model\ModuleConfigQuery;
|
||||
use Thelia\Model\OrderPostage;
|
||||
use Thelia\Model\TaxRuleQuery;
|
||||
use Thelia\Module\AbstractDeliveryModule;
|
||||
use Thelia\Module\Exception\DeliveryException;
|
||||
use Thelia\TaxEngine\Calculator;
|
||||
|
||||
/**
|
||||
* Class DHL
|
||||
@@ -33,9 +36,8 @@ class DHL extends AbstractDeliveryModule
|
||||
private static $prices = null;
|
||||
|
||||
const DOMAIN_NAME = 'dhl';
|
||||
const JSON_PRICE_RESOURCE = "/Config/prices.json";
|
||||
const JSON_PRICE_RESOURCE = '/Config/prices.json';
|
||||
const WEBSERVICE_URL = 'tracking_url';
|
||||
|
||||
const TRACKING_MESSAGE_NAME = 'mail_dhl';
|
||||
|
||||
|
||||
@@ -49,6 +51,7 @@ class DHL extends AbstractDeliveryModule
|
||||
return self::$prices;
|
||||
}
|
||||
|
||||
|
||||
public function postActivation(ConnectionInterface $con = null)
|
||||
{
|
||||
self::setConfigValue(self::WEBSERVICE_URL, "https://www.dhl.com/fr-fr/home/suivi.html?tracking-id=");
|
||||
@@ -58,7 +61,7 @@ class DHL extends AbstractDeliveryModule
|
||||
|
||||
// Create DHL shipping zones for home delivery
|
||||
$moduleId = self::getModuleId();
|
||||
$moduleConfiguration = json_decode(file_get_contents(__DIR__. '/Config/prices.json'));
|
||||
$moduleConfiguration = json_decode(file_get_contents(__DIR__. DHL::JSON_PRICE_RESOURCE));
|
||||
if (false === $moduleConfiguration) {
|
||||
throw new TheliaProcessException("Invalid JSON configuration for DHL module");
|
||||
}
|
||||
@@ -99,6 +102,7 @@ class DHL extends AbstractDeliveryModule
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function isValidDelivery(Country $country)
|
||||
{
|
||||
if (null !== $area = $this->getAreaForCountry($country)) {
|
||||
@@ -120,7 +124,6 @@ class DHL extends AbstractDeliveryModule
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -190,7 +193,20 @@ class DHL extends AbstractDeliveryModule
|
||||
$cartWeight
|
||||
);
|
||||
|
||||
return $postage;
|
||||
$orderPostage = new OrderPostage();
|
||||
$taxRule = TaxRuleQuery::create()->findOneByIsDefault(true);
|
||||
|
||||
$tax = (new Calculator())
|
||||
->loadTaxRuleWithoutProduct($taxRule, $country)
|
||||
->getTaxAmountFromTaxedPrice($postage);
|
||||
|
||||
$orderPostage->setAmount($postage);
|
||||
$orderPostage->setAmountTax($tax);
|
||||
$orderPostage->setTaxRuleTitle(
|
||||
$taxRule->setLocale($this->getRequest()->getSession()->getLang()->getLocale())->getTitle()
|
||||
);
|
||||
|
||||
return $orderPostage;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user