Module FedEx pour proposer le suivi du colis par FedEx + l'envoi d'un mail avec l'URL de suivi.
This commit is contained in:
@@ -22,17 +22,9 @@
|
||||
</service>
|
||||
</services>
|
||||
|
||||
<!-- <services>-->
|
||||
<!-- <service id="area.deleted.listener" class="FedEx\EventListener\AreaDeletedListener" scope="request">-->
|
||||
<!-- <tag name="kernel.event_subscriber"/>-->
|
||||
<!-- <argument type="service" id="request" />-->
|
||||
<!-- </service>-->
|
||||
<!-- </services>-->
|
||||
|
||||
<hooks>
|
||||
<hook id="fedex.hook" class="FedEx\Hook\HookManager">
|
||||
<tag name="hook.event_listener" event="module.configuration" type="back" method="onModuleConfiguration" />
|
||||
<tag name="hook.event_listener" event="module.config-js" type="back" templates="render:assets/js/module-configuration-js.html" />
|
||||
</hook>
|
||||
</hooks>
|
||||
</config>
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
{"1": {
|
||||
"_info": "area 1 : France",
|
||||
"slices": {
|
||||
"0.25": 5.23,
|
||||
"0.5": 6.13,
|
||||
"0.75": 6.89,
|
||||
"1": 7.51,
|
||||
"2": 8.50,
|
||||
"5": 10.93,
|
||||
"10": 15.68,
|
||||
"30": 23.28
|
||||
}
|
||||
}, "2": {
|
||||
"_info": "area 2 : A Zone - Union Europ\u00e9enne et Suisse",
|
||||
"slices": {
|
||||
"0.5": 11.54,
|
||||
"1": 14.11,
|
||||
"2": 15.68,
|
||||
"5": 20.14,
|
||||
"10": 33.25,
|
||||
"20": 55.10,
|
||||
"30": 55.10
|
||||
}
|
||||
}, "3": {
|
||||
"_info": "area 3 : B Zone - Pays de l\u2019Europe de l\u2019Est (hors Union Europ\u00e9enne et Russie), Norv\u00e8ge, Maghreb",
|
||||
"slices": {
|
||||
"0.5": 15.39,
|
||||
"1": 18.38,
|
||||
"2": 20.00,
|
||||
"5": 25.65,
|
||||
"10": 42.75,
|
||||
"20": 66.50
|
||||
}
|
||||
}, "4": {
|
||||
"_info": "area 4 : C Zone - Autres destinations",
|
||||
"slices": {
|
||||
"0.5": 22.52,
|
||||
"1": 24.99,
|
||||
"2": 34.30,
|
||||
"5": 50.35,
|
||||
"10": 95.00,
|
||||
"20": 152.00
|
||||
}
|
||||
}, "5": {
|
||||
"_info": "area 5 : France OM1",
|
||||
"slices": {
|
||||
"0.5": 8.69,
|
||||
"1": 13.16,
|
||||
"2": 17.96,
|
||||
"5": 26.60,
|
||||
"10": 42.75,
|
||||
"30": 95.95
|
||||
}
|
||||
}, "6": {
|
||||
"_info": "area 6 : France OM2",
|
||||
"slices": {
|
||||
"0.5": 10.40,
|
||||
"1": 15.72,
|
||||
"2": 27.74,
|
||||
"5": 46.08,
|
||||
"10": 90.25,
|
||||
"30": 237.50
|
||||
}
|
||||
}}
|
||||
@@ -10,4 +10,5 @@
|
||||
<route id="fedex.configuration" path="/admin/module/fedex/configuration/update" methods="post">
|
||||
<default key="_controller">FedEx\Controller\Configuration::editConfiguration</default>
|
||||
</route>
|
||||
|
||||
</routes>
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace FedEx\Controller;
|
||||
|
||||
use FedEx\FedEx;
|
||||
use FedEx\Model\Config\FedExConfigValue;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Thelia\Controller\Admin\BaseAdminController;
|
||||
use Thelia\Core\Security\AccessManager;
|
||||
@@ -36,7 +35,7 @@ class Configuration extends BaseAdminController
|
||||
$data = $validateForm->getData();
|
||||
|
||||
FedEx::setConfigValue(
|
||||
FedExConfigValue::TRACKING_URL,
|
||||
FedEx::TRACKING_URL_PARAMETER,
|
||||
$data["tracking_url"]
|
||||
);
|
||||
|
||||
|
||||
@@ -13,16 +13,16 @@ use Thelia\Module\Exception\DeliveryException;
|
||||
|
||||
class FedEx extends AbstractDeliveryModule
|
||||
{
|
||||
const DOMAIN_NAME = 'fedex';
|
||||
|
||||
protected $request;
|
||||
protected $dispatcher;
|
||||
const TRACKING_URL = 'tracking_url';
|
||||
|
||||
const TRACKING_URL_PARAMETER = 'tracking_url';
|
||||
const DEFAULT_TRACKING_URL = "https://www.fedex.com/apps/fedextrack/?action=track&trackingnumber=";
|
||||
private static $prices = null;
|
||||
|
||||
const JSON_PRICE_RESOURCE = "/Config/prices.json";
|
||||
|
||||
const DOMAIN_NAME = 'fedex';
|
||||
|
||||
public static function getPrices()
|
||||
{
|
||||
if (null === self::$prices) {
|
||||
@@ -34,7 +34,7 @@ class FedEx extends AbstractDeliveryModule
|
||||
|
||||
public function postActivation(ConnectionInterface $con = null)
|
||||
{
|
||||
self::setConfigValue(FedExConfigValue::TRACKING_URL, "https://www.fedex.com/apps/fedextrack/?action=track&trackingnumber=");
|
||||
self::setConfigValue(FedEx::TRACKING_URL_PARAMETER, FedEx::DEFAULT_TRACKING_URL);
|
||||
|
||||
$database = new Database($con);
|
||||
$database->insertSql(null, array(__DIR__ . '/Config/thelia.sql'));
|
||||
@@ -43,10 +43,6 @@ class FedEx extends AbstractDeliveryModule
|
||||
|
||||
public function isValidDelivery(Country $country, State $state = null)
|
||||
{
|
||||
if (0 == self::getConfigValue(FedExConfigValue::ENABLED, 1)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (null !== $area = $this->getAreaForCountry($country, $state)) {
|
||||
$areaId = $area->getId();
|
||||
|
||||
@@ -144,20 +140,4 @@ class FedEx extends AbstractDeliveryModule
|
||||
return $postage;
|
||||
}
|
||||
|
||||
public function update($currentVersion, $newVersion, ConnectionInterface $con = null)
|
||||
{
|
||||
$uploadDir = __DIR__ . '/Config/prices.json';
|
||||
|
||||
// $database = new Database($con);
|
||||
// $tableExists = $database->execute("SHOW TABLES LIKE 'FedEx_freeshipping'")->rowCount();
|
||||
// if (FedEx::getConfigValue(FedExConfigValue::FREE_SHIPPING, null) == null && $tableExists) {
|
||||
// $result = $database->execute('SELECT active FROM FedEx_freeshipping WHERE id=1')->fetch()["active"];
|
||||
// FedEx::setConfigValue(FedExConfigValue::FREE_SHIPPING, $result);
|
||||
// $database->execute("DROP TABLE `FedEx_freeshipping`");
|
||||
// }
|
||||
|
||||
if (is_readable($uploadDir) && FedEx::getConfigValue(FedExConfigValue::PRICES, null) == null) {
|
||||
FedEx::setConfigValue(FedExConfigValue::PRICES, file_get_contents($uploadDir));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
namespace FedEx\Form;
|
||||
|
||||
use FedEx\FedEx;
|
||||
use FedEx\Model\Config\Base\FedExConfigValue;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Thelia\Form\BaseForm;
|
||||
|
||||
/**
|
||||
@@ -18,9 +17,12 @@ class Configuration extends BaseForm
|
||||
{
|
||||
$this->formBuilder
|
||||
->add(
|
||||
FedEx::TRACKING_URL,
|
||||
'text',
|
||||
FedEx::TRACKING_URL_PARAMETER,
|
||||
'url',
|
||||
[
|
||||
'constraints' => [
|
||||
new NotBlank(),
|
||||
],
|
||||
'label' => $this->translator->trans('FedEx parcel tracking URL', [], FedEx::DOMAIN_NAME),
|
||||
'label_attr' => [
|
||||
'help' => $this->translator->trans('This is the parcel tracking URL for FedEx.', [], FedEx::DOMAIN_NAME)
|
||||
|
||||
@@ -26,7 +26,7 @@ return array(
|
||||
'Processing' => 'Processing',
|
||||
'REF' => 'REF',
|
||||
'Sent' => 'Sent',
|
||||
'This is the parcel tracking URL for FedEx.' => 'This is the parcel tracking URL for FedEx.',
|
||||
'This is the parcel tracking URL for FedEx.' => 'Please indicate FedEx parcel tracking`s WebService URL : last character must be symbol = ',
|
||||
'Total taxed amount' => 'Total taxed amount',
|
||||
'Weight up to ... (kg)' => 'Weight up to ... (kg)',
|
||||
'Number of packages' => 'Number of packages',
|
||||
|
||||
@@ -1,35 +1,25 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'*If you choose this option, the exported orders would not be available on this page anymore' => '* Si vous choisissez cette option, les commandes exportées ne seront plus affichée sur cette page.',
|
||||
return array(
|
||||
'Actions' => 'Actions',
|
||||
'An error occured' => 'Une erreur est survenue',
|
||||
'Area : ' => 'Zone de livraison : ',
|
||||
'Cancel' => 'Annuler',
|
||||
'FedEx Module allows to send your products all around the world with FedEx.' => 'FedEx vous permet d’expédier vos colis dans le monde entier avec FedEx',
|
||||
'Create' => 'Créer',
|
||||
'Create a new price slice' => 'Créer une nouvelle tranche de prix',
|
||||
'Create a price slice' => 'Créer une tranche de prix',
|
||||
'Customer' => 'Client',
|
||||
'Date' => 'Date',
|
||||
'Delete' => 'Supprimer',
|
||||
'Delete a price slice' => 'Supprimer une tranche de prix',
|
||||
'Delete this price slice' => 'Supprimer cette tranche de prix',
|
||||
'Do not change' => 'Ne pas modifier',
|
||||
'Do you really want to delete this slice ?' => 'Confirmez-vous la suppression de cette tranche de prix',
|
||||
'Edit' => 'Modifier',
|
||||
'Edit a price slice' => 'Modifier une tranche de prix',
|
||||
'Edit this price slice' => 'Modifier cette tranche de prix',
|
||||
'FedEx parcel tracking URL' => 'URL de suivi des colis FedEx',
|
||||
'Number of packages' => 'Nombre de colis',
|
||||
'Packages weight' => 'Poids des colis',
|
||||
'FedEx parcel tracking URL' => 'URL du WebService de suivi des colis FedEx',
|
||||
'FedEx Module allows to send your products all around the world with FedEx.' => 'FedEx vous permet d’expédier vos colis dans le monde entier avec FedEx',
|
||||
'Please change the access rights' => 'Merci de modifier les droits d\'accès',
|
||||
'Price (€)' => 'Prix (€)',
|
||||
'Price slices' => 'Prix et poids',
|
||||
'Processing' => 'Traitement',
|
||||
'REF' => 'REF',
|
||||
'Sent' => 'Envoyée',
|
||||
'This is the parcel tracking URL for FedEx.' => 'Il s\'agit de l\'URL fournie par FedEx afin de suivre les expéditions de ses colis.',
|
||||
'Total taxed amount' => 'Total TTC',
|
||||
'Save' => 'Sauvegarder',
|
||||
'This is the parcel tracking URL for FedEx.' => 'Veuillez saisir l\'URL de suivi des colis FedEx : le dernier caractère doit être le symbole =',
|
||||
'Weight up to ... (kg)' => 'Jusqu\'au poids (Kg)',
|
||||
];
|
||||
);
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
return array(
|
||||
'Can\'t read Config directory' => 'Le dossier Config ne peut être lu',
|
||||
'Can\'t read file' => 'Le fichier suivant ne peut être lu',
|
||||
'Can\'t write Config directory' => 'Le dossier Config ne peut être écrit',
|
||||
'Can\'t write file' => 'Le fichier suivant ne peut être écrit',
|
||||
'FedEx delivery unavailable for the delivery country' => 'La livraison par FedEx n\'est pas disponible dans ce pays',
|
||||
'FedEx delivery unavailable for this cart weight (%weight kg)' => 'La livraison par FedEx n\'est pas disponible pour un panier de %weight Kg',
|
||||
'select a valid status' => 'Choisissez un statut de commande valide.',
|
||||
];
|
||||
'FedEx parcel tracking URL' => 'URL du WebService de suivi des colis FedEx',
|
||||
'This is the parcel tracking URL for FedEx.' => 'Veuillez saisir l\'URL de suivi des colis FedEx : le dernier caractère doit être le symbole =',
|
||||
);
|
||||
|
||||
@@ -10,15 +10,12 @@ use Thelia\Core\Template\ParserInterface;
|
||||
use Thelia\Log\Tlog;
|
||||
use Thelia\Mailer\MailerFactory;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Model\MessageQuery;
|
||||
use Thelia\Model\OrderStatus;
|
||||
use Thelia\Module\PaymentModuleInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Class SendMail
|
||||
* @package FedEx\Listener
|
||||
* @author Manuel Raynaud <manu@raynaud.io>
|
||||
* @author Laurent LE CORRE <laurent@thecoredev.fr>
|
||||
*/
|
||||
class SendMail implements EventSubscriberInterface
|
||||
{
|
||||
@@ -51,6 +48,7 @@ class SendMail implements EventSubscriberInterface
|
||||
'order_ref' => $order->getRef(),
|
||||
'order_date' => $order->getCreatedAt(),
|
||||
'update_date' => $order->getUpdatedAt(),
|
||||
'tracking_url' => FedEx::getConfigValue('tracking_url',$FedEx::DEFAULT_TRACKING_URL),
|
||||
'package' => $order->getDeliveryRef()
|
||||
]
|
||||
);
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
{javascripts file="assets/js/bootstrap-switch/bootstrap-switch.js"}
|
||||
<script src="{$asset_url}"></script>
|
||||
{/javascripts}
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
/*
|
||||
$(".freeshipping-activation-FedEx").bootstrapSwitch();
|
||||
|
||||
$(".freeshipping-activation-FedEx").on("switch-change", function(e, data){
|
||||
var is_checked = data.value;
|
||||
var form = $("#freeshippingform");
|
||||
$('body').append('<div class="modal-backdrop fade in" id="loading-event"><div class="loading"></div></div>');
|
||||
$.ajax({
|
||||
url: form.attr('action'),
|
||||
type: form.attr('method'),
|
||||
data: form.serialize()
|
||||
}).done(function(){
|
||||
$("#loading-event").remove();
|
||||
})
|
||||
.success(function() {
|
||||
if (is_checked) {
|
||||
$('#config-btn-0').removeClass('disabled');
|
||||
$('#table-prices-FedEx').hide('slow');
|
||||
} else {
|
||||
$('#config-btn-0').addClass('disabled');
|
||||
$('#table-prices-FedEx').show('slow');
|
||||
}
|
||||
})
|
||||
.fail(function(jqXHR, textStatus, errorThrown){
|
||||
$("#loading-event").remove();
|
||||
$('#freeshipping-failed-body').html(jqXHR.responseJSON.error);
|
||||
$("#freeshipping-failed").modal("show");
|
||||
});
|
||||
});
|
||||
*/
|
||||
});
|
||||
</script>
|
||||
@@ -13,21 +13,6 @@
|
||||
<p>{intl d='fedex.bo.default' l="FedEx Module allows to send your products all around the world with FedEx."}</p>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="freeshipping-failed" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h3>{intl d='fedex.bo.default' l="An error occured"}</h3>
|
||||
</div>
|
||||
<div class="modal-body" id="freeshipping-failed-body">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="general-block-decorator">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
@@ -35,23 +20,9 @@
|
||||
<form method="POST" action="{url path='/admin/module/fedex/configuration/update'}">
|
||||
{form_hidden_fields form=$form}
|
||||
|
||||
{form_field form=$form field="tracking_url"}
|
||||
<div class="form-group">
|
||||
<label class="control-label" for="{$label_attr.for}">
|
||||
<input type="text" name="{$name}" id="{$label_attr.for}" />
|
||||
{$label}
|
||||
|
||||
{form_error form=$form field="tracking_url" value={module_config module="FedEx" key='tracking_url' locale="en_US"}}
|
||||
<br />
|
||||
<span class="error">{$message}</span>
|
||||
{/form_error}
|
||||
</label>
|
||||
{if ! empty($label_attr.help)}
|
||||
<span class="help-block">{$label_attr.help}</span>
|
||||
{/if}
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
{loop type="module-config" name="boucle" module="FedEx" variable="tracking_url"}
|
||||
{render_form_field field="tracking_url" value=$VALUE}
|
||||
{/loop}
|
||||
<button type="submit" name="fedex_save_configuration" value="save" class="form-submit-button btn btn-sm btn-default" title="{intl d='fedex.bo.default' l='Save'}">
|
||||
{intl d='fedex.bo.default' l='Save'}
|
||||
</button>
|
||||
|
||||
Reference in New Issue
Block a user