Encore des modifs sur module DHL
This commit is contained in:
@@ -20,10 +20,8 @@
|
||||
<argument type="service" id="mailer"/>
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
</services>
|
||||
|
||||
<services>
|
||||
<service id="area.deleted.listener" class="DHL\EventListener\AreaDeletedListener" scope="request">
|
||||
<service id="area.deleted.listener" class="DHL\Listener\AreaDeletedListener" scope="request">
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
<argument type="service" id="request" />
|
||||
</service>
|
||||
|
||||
@@ -1,5 +1,17 @@
|
||||
SET FOREIGN_KEY_CHECKS = 0;
|
||||
|
||||
-- Suppression de la table des tarfis
|
||||
DROP TABLE IF EXISTS `dhl_delivery_price`;
|
||||
|
||||
-- Suppression du mail
|
||||
SET @var := 0;
|
||||
SELECT @var := `id` FROM `message` WHERE name="mail_dhl";
|
||||
DELETE FROM `message` WHERE `id`=@var;
|
||||
DELETE FROM `message_i18n` WHERE `id`=@var;
|
||||
|
||||
-- Suppression des zones dédiées DHL
|
||||
DELETE FROM `country_area` WHERE `area_id` IN (SELECT `id` FROM `area` WHERE name LIKE 'DHL - Delivery Zone%');
|
||||
DELETE FROM `area_delivery_module` WHERE `area_id` IN (SELECT `id` FROM `area` WHERE name LIKE 'DHL - Delivery Zone%');
|
||||
DELETE FROM `area` WHERE name LIKE 'DHL - Delivery Zone%';
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace DHL\Form;
|
||||
|
||||
use DHL\DHL;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Thelia\Form\BaseForm;
|
||||
|
||||
/**
|
||||
@@ -19,6 +20,7 @@ class Configuration extends BaseForm
|
||||
DHL::WEBSERVICE_URL,
|
||||
'text',
|
||||
[
|
||||
'constraints' => [new NotBlank()],
|
||||
'label' => $this->translator->trans('DHL tracking URL', [], DHL::DOMAIN_NAME),
|
||||
'label_attr' => [
|
||||
'help' => $this->translator->trans('This is the URL of the DHL tracking service.', [], DHL::DOMAIN_NAME)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace DHL\EventListener;
|
||||
namespace DHL\Listener;
|
||||
|
||||
use DHL\DHL;
|
||||
use DHL\Model\Config\DHLConfigValue;
|
||||
Reference in New Issue
Block a user