Version Notes
Lire le manuel d'installation
Download this release
Release Info
| Developer | Magento Core Team |
| Extension | ColiPoste_La_Poste_So_Colissimo |
| Version | 1.0.2 |
| Comparing to | |
| See all releases | |
Version 1.0.2
- app/code/community/LaPoste/SoColissimoSimplicite/Block/Form.php +98 -0
- app/code/community/LaPoste/SoColissimoSimplicite/Block/Onepage.php +76 -0
- app/code/community/LaPoste/SoColissimoSimplicite/Block/Onepage/Shipping/Method/Available.php +118 -0
- app/code/community/LaPoste/SoColissimoSimplicite/Block/Onepage/Shipping/Method/Available/Item.php +39 -0
- app/code/community/LaPoste/SoColissimoSimplicite/Helper/Data.php +266 -0
- app/code/community/LaPoste/SoColissimoSimplicite/Model/Carrier/ShippingMethod.php +135 -0
- app/code/community/LaPoste/SoColissimoSimplicite/Model/Mysql4/Transaction.php +30 -0
- app/code/community/LaPoste/SoColissimoSimplicite/Model/Mysql4/Transaction/Collection.php +31 -0
- app/code/community/LaPoste/SoColissimoSimplicite/Model/Observer.php +192 -0
- app/code/community/LaPoste/SoColissimoSimplicite/Model/System/Config/Source/Shipping/Amountbasetype.php +42 -0
- app/code/community/LaPoste/SoColissimoSimplicite/Model/Transaction.php +139 -0
- app/code/community/LaPoste/SoColissimoSimplicite/controllers/FormController.php +208 -0
- app/code/community/LaPoste/SoColissimoSimplicite/etc/config.xml +160 -0
- app/code/community/LaPoste/SoColissimoSimplicite/etc/system.xml +169 -0
- app/design/frontend/default/default/layout/socolissimosimplicite.xml +85 -0
- app/design/frontend/default/default/template/socolissimosimplicite/form.phtml +115 -0
- app/design/frontend/default/default/template/socolissimosimplicite/form/failure.phtml +24 -0
- app/design/frontend/default/default/template/socolissimosimplicite/onepage/shipping_method.phtml +78 -0
- app/design/frontend/default/default/template/socolissimosimplicite/onepage/shipping_method/available.phtml +54 -0
- app/design/frontend/default/default/template/socolissimosimplicite/onepage/shipping_method/available/default.phtml +30 -0
- app/design/frontend/default/default/template/socolissimosimplicite/onepage/shipping_method/available/socolissimosimplicite.phtml +29 -0
- app/etc/modules/LaPoste_SoColissimoSimplicite.xml +34 -0
- app/locale/fr_FR/LaPoste_SoColissimoSimplicite.csv +3 -0
- package.xml +28 -0
app/code/community/LaPoste/SoColissimoSimplicite/Block/Form.php
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* @category LaPoste
|
| 16 |
+
* @package LaPoste_SoColissimoSimplicite
|
| 17 |
+
* @copyright Copyright (c) 2010 La Poste
|
| 18 |
+
* @author Smile (http://www.smile.fr)
|
| 19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 20 |
+
*/
|
| 21 |
+
|
| 22 |
+
/**
|
| 23 |
+
* Formulaire de soumission pour l'accès à l'interface SO Colissimo en front office.
|
| 24 |
+
*/
|
| 25 |
+
class LaPoste_SoColissimoSimplicite_Block_Form extends Mage_Core_Block_Template
|
| 26 |
+
{
|
| 27 |
+
protected $_carrierInstance;
|
| 28 |
+
|
| 29 |
+
/**
|
| 30 |
+
* Retourne la ligne n° $line des informations (rue, étage, immeuble, etc.) de l'adresse
|
| 31 |
+
* de livraison de la commande en cours.
|
| 32 |
+
* @param int $line
|
| 33 |
+
* @return string
|
| 34 |
+
*/
|
| 35 |
+
public function getShippingAddressStreet($line = 1) {
|
| 36 |
+
$arrayStreet = $this->getShippingAddress()->getStreet();
|
| 37 |
+
$streetLine = '';
|
| 38 |
+
if (0 < $line && $line <= count($arrayStreet)) {
|
| 39 |
+
$streetLine = $arrayStreet[$line-1];
|
| 40 |
+
}
|
| 41 |
+
return $streetLine;
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
/**
|
| 45 |
+
* Retourne le message à afficher lors de la redirection vers le front de
|
| 46 |
+
* SO Colissimo Simplicité.
|
| 47 |
+
* @return string
|
| 48 |
+
*/
|
| 49 |
+
public function getRedirectMessage() {
|
| 50 |
+
return $this->helper('socolissimosimplicite')->getRedirectMessage();
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
/**
|
| 54 |
+
* Retourne l'identifiant FO d'accès à la plateforme SO Colissimo (front-office)
|
| 55 |
+
* @return string
|
| 56 |
+
*/
|
| 57 |
+
public function getAccountID() {
|
| 58 |
+
return $this->helper('socolissimosimplicite')->getAccountId();
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
/**
|
| 62 |
+
* Retourne la clé de cryptage pour l'accès à la plateforme SO Colissimo (front-office)
|
| 63 |
+
* @return string
|
| 64 |
+
*/
|
| 65 |
+
public function getEncryptionKey() {
|
| 66 |
+
return $this->helper('socolissimosimplicite')->getEncryptionKey();
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
/**
|
| 70 |
+
* Retourne l'URL d'accès à la plateforme SO Colissimo (front-office)
|
| 71 |
+
* @return string
|
| 72 |
+
*/
|
| 73 |
+
public function getUrlFoWithReturnUrlKo() {
|
| 74 |
+
$urlFo = $this->helper('socolissimosimplicite')->getUrlFo();
|
| 75 |
+
$returnUrlKo = $this->helper('socolissimosimplicite')->getFailureUrl();
|
| 76 |
+
return $urlFo.'?trReturnUrlKo='.$returnUrlKo;
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
/**
|
| 80 |
+
* Retourne la signature calculée à partir de certains champs.
|
| 81 |
+
* @return string
|
| 82 |
+
*/
|
| 83 |
+
public function getSignature() {
|
| 84 |
+
return $this->helper('socolissimosimplicite')->generateSignature(
|
| 85 |
+
$this->_carrierInstance,
|
| 86 |
+
$this->getShippingAddress(),
|
| 87 |
+
$this->_transactionId
|
| 88 |
+
);
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
/**
|
| 92 |
+
* Retourne l'url complète appelée en cas de succès
|
| 93 |
+
* @return string
|
| 94 |
+
*/
|
| 95 |
+
public function getSuccessUrl() {
|
| 96 |
+
return $this->helper('socolissimosimplicite')->getSuccessUrl();
|
| 97 |
+
}
|
| 98 |
+
}
|
app/code/community/LaPoste/SoColissimoSimplicite/Block/Onepage.php
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* @category LaPoste
|
| 16 |
+
* @package LaPoste_SoColissimoSimplicite
|
| 17 |
+
* @copyright Copyright (c) 2010 La Poste
|
| 18 |
+
* @author Smile (http://www.smile.fr)
|
| 19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 20 |
+
*/
|
| 21 |
+
class LaPoste_SoColissimoSimplicite_Block_Onepage extends Mage_Checkout_Block_Onepage
|
| 22 |
+
{
|
| 23 |
+
protected $_stepToActivate;
|
| 24 |
+
|
| 25 |
+
/**
|
| 26 |
+
* Met à jour les étapes précédentes lorsqu'une étape autre que la 1ère
|
| 27 |
+
* étape est à afficher
|
| 28 |
+
*/
|
| 29 |
+
protected function _beforeToHtml() {
|
| 30 |
+
|
| 31 |
+
parent::_beforeToHtml();
|
| 32 |
+
|
| 33 |
+
//on cherche en session si une étape est à afficher directement
|
| 34 |
+
$checkout = Mage::getSingleton('checkout/session');
|
| 35 |
+
$this->_stepToActivate = false;
|
| 36 |
+
|
| 37 |
+
if ($checkout->getData('socolissimosimplicite_checkout_onepage_nextstep')) {
|
| 38 |
+
$this->_stepToActivate = $checkout->getData('socolissimosimplicite_checkout_onepage_nextstep');
|
| 39 |
+
}
|
| 40 |
+
$steps = $this->getSteps();
|
| 41 |
+
|
| 42 |
+
//on force l'activation des étapes précédant l'étape que l'on souhaite
|
| 43 |
+
//afficher + de l'étape à afficher
|
| 44 |
+
if ($this->_stepToActivate && array_key_exists($this->_stepToActivate,$steps)) {
|
| 45 |
+
|
| 46 |
+
foreach ($steps as $key => $data) {
|
| 47 |
+
//permet d'afficher le contenu de l'étape en cours et de revenir
|
| 48 |
+
//sur les étapes précédentes
|
| 49 |
+
$this->getCheckout()->setStepData($key,'allow',true);
|
| 50 |
+
|
| 51 |
+
if ($key == $this->_stepToActivate) {
|
| 52 |
+
break;
|
| 53 |
+
}
|
| 54 |
+
//permet d'afficher la progression
|
| 55 |
+
$this->getCheckout()->setStepData($key,'complete',true);
|
| 56 |
+
}
|
| 57 |
+
}
|
| 58 |
+
return $this;
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
/**
|
| 62 |
+
* Retourne le code de l'étape à afficher dans le tunnel de commande.
|
| 63 |
+
* @return string
|
| 64 |
+
*/
|
| 65 |
+
public function getActiveStep()
|
| 66 |
+
{
|
| 67 |
+
if ($this->_stepToActivate) {
|
| 68 |
+
$activeStep = $this->_stepToActivate;
|
| 69 |
+
} elseif ($this->isCustomerLoggedIn()) {
|
| 70 |
+
$activeStep = 'billing';
|
| 71 |
+
} else {
|
| 72 |
+
$activeStep = 'login';
|
| 73 |
+
}
|
| 74 |
+
return $activeStep;
|
| 75 |
+
}
|
| 76 |
+
}
|
app/code/community/LaPoste/SoColissimoSimplicite/Block/Onepage/Shipping/Method/Available.php
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* @category LaPoste
|
| 16 |
+
* @package LaPoste_SoColissimoSimplicite
|
| 17 |
+
* @copyright Copyright (c) 2010 La Poste
|
| 18 |
+
* @author Smile (http://www.smile.fr)
|
| 19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 20 |
+
*/
|
| 21 |
+
|
| 22 |
+
/**
|
| 23 |
+
* Modes de livraison disponibles
|
| 24 |
+
*/
|
| 25 |
+
class LaPoste_SoColissimoSimplicite_Block_Onepage_Shipping_Method_Available
|
| 26 |
+
extends Mage_Checkout_Block_Onepage_Shipping_Method_Available
|
| 27 |
+
{
|
| 28 |
+
protected $_itemRenders = array();
|
| 29 |
+
|
| 30 |
+
public function __construct()
|
| 31 |
+
{
|
| 32 |
+
parent::__construct();
|
| 33 |
+
|
| 34 |
+
//Rendu par défaut
|
| 35 |
+
$this->addItemRender(
|
| 36 |
+
'default',
|
| 37 |
+
'socolissimosimplicite/onepage_shipping_method_available',
|
| 38 |
+
'socolissimosimplicite/onepage/shipping_method/available/default.phtml'
|
| 39 |
+
);
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
/**
|
| 43 |
+
* Ajoute une correspondance dans la table des rendus des modes de livraison.
|
| 44 |
+
* Cela permet de personnaliser l'affichage d'un mode de livraison parmi la
|
| 45 |
+
* liste des modes proposés lors du passage d'une commande.
|
| 46 |
+
* @param string $type
|
| 47 |
+
* @param string $block
|
| 48 |
+
* @param string $template
|
| 49 |
+
* @return LaPoste_SoColissimoSimplicite_Block_Onepage_Shipping_Method_Available
|
| 50 |
+
*/
|
| 51 |
+
public function addItemRender($type, $block, $template)
|
| 52 |
+
{
|
| 53 |
+
$this->_itemRenders[$type] = array(
|
| 54 |
+
'block' => $block,
|
| 55 |
+
'template' => $template,
|
| 56 |
+
'blockInstance' => null
|
| 57 |
+
);
|
| 58 |
+
return $this;
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
/**
|
| 62 |
+
* Retourne le renderer approprié selon le mode de livraison.
|
| 63 |
+
* Le renderer par défaut est "default".
|
| 64 |
+
* @param string $type exemples : default|socolissimosimplicite
|
| 65 |
+
* @return array
|
| 66 |
+
*/
|
| 67 |
+
public function getItemRenderer($type)
|
| 68 |
+
{
|
| 69 |
+
if (!isset($this->_itemRenders[$type])) {
|
| 70 |
+
$type = 'default';
|
| 71 |
+
}
|
| 72 |
+
if (is_null($this->_itemRenders[$type]['blockInstance'])) {
|
| 73 |
+
$this->_itemRenders[$type]['blockInstance'] = $this->getLayout()
|
| 74 |
+
->createBlock($this->_itemRenders[$type]['block'])
|
| 75 |
+
->setTemplate($this->_itemRenders[$type]['template'])
|
| 76 |
+
->setRenderedBlock($this);
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
return $this->_itemRenders[$type]['blockInstance'];
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
/**
|
| 83 |
+
* Retourne le code html du mode de livraison donné.
|
| 84 |
+
* @param Mage_Shipping_Model_Carrier_Abstract $item
|
| 85 |
+
* @return string
|
| 86 |
+
*/
|
| 87 |
+
public function getItemHtml($item)
|
| 88 |
+
{
|
| 89 |
+
//le code html retourné dépend du mode de livraison
|
| 90 |
+
$renderer = $this->getItemRenderer($item->getMethod())->setRate($item);
|
| 91 |
+
return $renderer->toHtml();
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
/**
|
| 95 |
+
* Vérifie si la plateforme socolissimo est disponible
|
| 96 |
+
*
|
| 97 |
+
* @return boolean
|
| 98 |
+
*/
|
| 99 |
+
public function getServiceIsAvailable()
|
| 100 |
+
{
|
| 101 |
+
$helper = Mage::helper('socolissimosimplicite');
|
| 102 |
+
if ($helper->getServiceIsAvailable() and $helper->getServiceIsAvailableUrl() != '') {
|
| 103 |
+
return $helper->checkserviceAvailability();
|
| 104 |
+
}
|
| 105 |
+
return true;
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
/**
|
| 109 |
+
* Retourne le message d'erreur si la plateforme socolissimo n'est pas disponible
|
| 110 |
+
* @return string
|
| 111 |
+
*/
|
| 112 |
+
public function getServiceNotAvailableMessage()
|
| 113 |
+
{
|
| 114 |
+
$helper = Mage::helper('socolissimosimplicite');
|
| 115 |
+
return $helper->getServiceNotAvailableMessage();
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
}
|
app/code/community/LaPoste/SoColissimoSimplicite/Block/Onepage/Shipping/Method/Available/Item.php
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* @category LaPoste
|
| 16 |
+
* @package LaPoste_SoColissimoSimplicite
|
| 17 |
+
* @copyright Copyright (c) 2010 La Poste
|
| 18 |
+
* @author Smile (http://www.smile.fr)
|
| 19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 20 |
+
*/
|
| 21 |
+
|
| 22 |
+
/**
|
| 23 |
+
* Mode de livraison
|
| 24 |
+
*/
|
| 25 |
+
class LaPoste_SoColissimoSimplicite_Block_Onepage_Shipping_Method_Available_Item
|
| 26 |
+
extends Mage_Checkout_Block_Onepage_Shipping_Method_Available
|
| 27 |
+
{
|
| 28 |
+
|
| 29 |
+
protected $_shippingMethod;
|
| 30 |
+
|
| 31 |
+
public function getShippingMethod($rate)
|
| 32 |
+
{
|
| 33 |
+
if (is_null($this->_shippingMethod)) {
|
| 34 |
+
$this->_shippingMethod = $rate->getCarrierInstance();
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
return $this->_shippingMethod;
|
| 38 |
+
}
|
| 39 |
+
}
|
app/code/community/LaPoste/SoColissimoSimplicite/Helper/Data.php
ADDED
|
@@ -0,0 +1,266 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* @category LaPoste
|
| 16 |
+
* @package LaPoste_SoColissimoSimplicite
|
| 17 |
+
* @copyright Copyright (c) 2010 La Poste
|
| 18 |
+
* @author Smile (http://www.smile.fr)
|
| 19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 20 |
+
*/
|
| 21 |
+
class LaPoste_SoColissimoSimplicite_Helper_Data extends Mage_Core_Helper_Abstract
|
| 22 |
+
{
|
| 23 |
+
/**
|
| 24 |
+
* URL du formulaire de soumission à l'accès au front de SO Colissimo
|
| 25 |
+
* @var string
|
| 26 |
+
*/
|
| 27 |
+
const FORM_URL = 'socolissimosimplicite/form/send';
|
| 28 |
+
/**
|
| 29 |
+
* URL appelée en cas de succès suite à la sélection de la livraison
|
| 30 |
+
* dans l'interface SO Colissimo
|
| 31 |
+
* @var string
|
| 32 |
+
*/
|
| 33 |
+
const SUCCESS_URL = 'socolissimosimplicite/form/success';
|
| 34 |
+
/**
|
| 35 |
+
* URL appelée en cas d'échec suite à l'accès au front de SO Colissimo
|
| 36 |
+
* @var string
|
| 37 |
+
*/
|
| 38 |
+
const FAILURE_URL = 'socolissimosimplicite/form/failure';
|
| 39 |
+
|
| 40 |
+
/**
|
| 41 |
+
* Retourne l'url complète de la page contenant le formulaire à soumettre
|
| 42 |
+
* pour l'accès au front de SO Colissimo
|
| 43 |
+
* @return string
|
| 44 |
+
*/
|
| 45 |
+
public function getFormUrl()
|
| 46 |
+
{
|
| 47 |
+
return Mage::getUrl(self::FORM_URL);
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
/**
|
| 51 |
+
* Retourne l'url complète appelée en cas de succès suite à la
|
| 52 |
+
* sélection de la livraison dans l'interface SO Colissimo
|
| 53 |
+
* @return string
|
| 54 |
+
*/
|
| 55 |
+
public function getSuccessUrl()
|
| 56 |
+
{
|
| 57 |
+
return Mage::getUrl(self::SUCCESS_URL);
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
/**
|
| 61 |
+
* Retourne l'url complète appelée en cas d'échec suite à
|
| 62 |
+
* l'accès au front de SO Colissimo
|
| 63 |
+
* @return string
|
| 64 |
+
*/
|
| 65 |
+
public function getFailureUrl()
|
| 66 |
+
{
|
| 67 |
+
return Mage::getUrl(self::FAILURE_URL);
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
/**
|
| 71 |
+
* Retourne le code du mode de livraison tel qu'utilisé lors du passage
|
| 72 |
+
* d'une commande (code transporteur + mode).
|
| 73 |
+
* @return string
|
| 74 |
+
*/
|
| 75 |
+
public function getRateCode()
|
| 76 |
+
{
|
| 77 |
+
$shippingMethod = new LaPoste_SoColissimoSimplicite_Model_Carrier_ShippingMethod();
|
| 78 |
+
|
| 79 |
+
//le code du transporteur et le code du mode de livraison sont les mêmes
|
| 80 |
+
//cf Mage_Shipping_Model_Carrier_Abstract : un seul attribut "code" utilisé dans les deux cas
|
| 81 |
+
//les modes de livraison natifs sont également implémentés de cette manière
|
| 82 |
+
$carrierCode = $shippingMethod->getCarrierCode();
|
| 83 |
+
$methodCode = $shippingMethod->getCarrierCode();
|
| 84 |
+
|
| 85 |
+
return $carrierCode.'_'.$methodCode;
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
/**
|
| 89 |
+
* Retourne l'identifiant d'accès au FO de SO Colissimo Simplicité
|
| 90 |
+
* @return string
|
| 91 |
+
*/
|
| 92 |
+
public function getAccountId()
|
| 93 |
+
{
|
| 94 |
+
return Mage::getStoreConfig('carriers/socolissimosimplicite/account');
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
/**
|
| 98 |
+
* Retourne la clé de cryptage nécessaire à la génération de la signature
|
| 99 |
+
* pour l'accès au FO de SO Colissimo Simplicité.
|
| 100 |
+
* @return string
|
| 101 |
+
*/
|
| 102 |
+
public function getEncryptionKey()
|
| 103 |
+
{
|
| 104 |
+
return Mage::getStoreConfig('carriers/socolissimosimplicite/encryption_key');
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
/**
|
| 108 |
+
* Retourne l'url du front de SO Colissimo Simplicité
|
| 109 |
+
* @return string
|
| 110 |
+
*/
|
| 111 |
+
public function getUrlFo()
|
| 112 |
+
{
|
| 113 |
+
return Mage::getStoreConfig('carriers/socolissimosimplicite/url_fo');
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
/**
|
| 117 |
+
* Retourne le message à afficher lors du choix de mode de livraison,
|
| 118 |
+
* sous le titre.
|
| 119 |
+
* @return string
|
| 120 |
+
*/
|
| 121 |
+
public function getSelectMessage()
|
| 122 |
+
{
|
| 123 |
+
return Mage::getStoreConfig('carriers/socolissimosimplicite/selectmessage');
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
/**
|
| 127 |
+
* Retourne le message à afficher lors de la redirection vers le front de
|
| 128 |
+
* SO Colissimo Simplicité.
|
| 129 |
+
* @return string
|
| 130 |
+
*/
|
| 131 |
+
public function getRedirectMessage()
|
| 132 |
+
{
|
| 133 |
+
return Mage::getStoreConfig('carriers/socolissimosimplicite/redirectmessage');
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
/**
|
| 137 |
+
* Vérifie si la livraison dans les points de retrait est désactivée
|
| 138 |
+
* @return boolean
|
| 139 |
+
*/
|
| 140 |
+
public function isShipOutOfHomeDisabled()
|
| 141 |
+
{
|
| 142 |
+
return Mage::getStoreConfig('carriers/socolissimosimplicite/shipoutofhomeenabled') == '0';
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
/**
|
| 146 |
+
* Retourne l'url de vérification de la disponibilité de SO Colissimo Simplicité.
|
| 147 |
+
* @return string
|
| 148 |
+
*/
|
| 149 |
+
public function getServiceIsAvailableUrl()
|
| 150 |
+
{
|
| 151 |
+
return Mage::getStoreConfig('carriers/socolissimosimplicite/url_service_is_available');
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
/**
|
| 155 |
+
* Retourne si la vérification de la disponibilité de SO Colissimo Simplicité doit être effectuée.
|
| 156 |
+
* @return boolean
|
| 157 |
+
*/
|
| 158 |
+
public function getServiceIsAvailable()
|
| 159 |
+
{
|
| 160 |
+
return Mage::getStoreConfig('carriers/socolissimosimplicite/active_service_is_available') == '1';
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
+
/**
|
| 164 |
+
* Retourne le message à afficher si le service n'est pas disponible
|
| 165 |
+
* @return string
|
| 166 |
+
*/
|
| 167 |
+
public function getServiceNotAvailableMessage()
|
| 168 |
+
{
|
| 169 |
+
return Mage::getStoreConfig('carriers/socolissimosimplicite/not_available_message');
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
/**
|
| 173 |
+
* Retourne le tableau associant les codes de civilité de SO Colissimo avec les
|
| 174 |
+
* valeurs pouvant être définies dans Magento.
|
| 175 |
+
* Dans la config, la correspondance est fournir en JSON, le tableau correspondant
|
| 176 |
+
* est retourné.
|
| 177 |
+
* @return array
|
| 178 |
+
*/
|
| 179 |
+
public function getMapPrefix()
|
| 180 |
+
{
|
| 181 |
+
$map = Mage::getStoreConfig('carriers/socolissimosimplicite/mapprefix');
|
| 182 |
+
return json_decode($map,true); //TODOpeleq gérer une erreur ds le json ?
|
| 183 |
+
}
|
| 184 |
+
|
| 185 |
+
/**
|
| 186 |
+
* Retourne les frais de livraison correctement formatés pour la soumission auprès
|
| 187 |
+
* de SO Colissimo
|
| 188 |
+
* @param float $shippingPrice
|
| 189 |
+
* @param int $maxDecimalDigit
|
| 190 |
+
* @return float
|
| 191 |
+
*/
|
| 192 |
+
public function getFormatedShippingPrice($shippingPrice,$maxDecimalDigit = 2)
|
| 193 |
+
{
|
| 194 |
+
$formatedPrice = number_format($shippingPrice,$maxDecimalDigit,'.','');
|
| 195 |
+
return $formatedPrice;
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
/**
|
| 199 |
+
* Retourne le poids total de la commande correctement formaté pour la soumission
|
| 200 |
+
* auprès de SO Colissimo
|
| 201 |
+
* @param float $weight
|
| 202 |
+
* @return int
|
| 203 |
+
*/
|
| 204 |
+
public function getFormatedWeight($weight)
|
| 205 |
+
{
|
| 206 |
+
$weight = str_replace(',', '.', $weight);
|
| 207 |
+
$weight = $weight/1000; //converti kg en g
|
| 208 |
+
$formatedWeight = number_format($weight, 2, '.', '');
|
| 209 |
+
return $formatedWeight;
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
/**
|
| 213 |
+
* Retourne le code civilité de SO Colissimo correspondant au code
|
| 214 |
+
* civilité donné.
|
| 215 |
+
* @param string $prefixMagento
|
| 216 |
+
* @return string
|
| 217 |
+
*/
|
| 218 |
+
public function getPrefixForSoColissimo($prefixMagento)
|
| 219 |
+
{
|
| 220 |
+
$prefixSoCo = '';
|
| 221 |
+
$mapPrefix = $this->getMapPrefix();
|
| 222 |
+
if (in_array($prefixMagento,$mapPrefix)) {
|
| 223 |
+
$prefixSoCo = array_search($prefixMagento,$mapPrefix);
|
| 224 |
+
}
|
| 225 |
+
return $prefixSoCo;
|
| 226 |
+
}
|
| 227 |
+
|
| 228 |
+
/**
|
| 229 |
+
* Retourne la civilité correspondant au code civilité au format
|
| 230 |
+
* SO Colissimo donné.
|
| 231 |
+
* @param string $prefixSoCo
|
| 232 |
+
* @return string
|
| 233 |
+
*/
|
| 234 |
+
public function getPrefixForMagento($prefixSoCo)
|
| 235 |
+
{
|
| 236 |
+
$prefixMagento = '';
|
| 237 |
+
$mapPrefix = $this->getMapPrefix();
|
| 238 |
+
if (isset($mapPrefix[$prefixSoCo])) {
|
| 239 |
+
$prefixMagento = $mapPrefix[$prefixSoCo];
|
| 240 |
+
}
|
| 241 |
+
return $prefixMagento;
|
| 242 |
+
}
|
| 243 |
+
|
| 244 |
+
/**
|
| 245 |
+
* Vérifier que la plateforme socolissimo est disponible
|
| 246 |
+
*
|
| 247 |
+
* @return boolean
|
| 248 |
+
*/
|
| 249 |
+
public function checkServiceAvailability()
|
| 250 |
+
{
|
| 251 |
+
// exécuter la requête GET et récupérer l'état du service
|
| 252 |
+
$c = curl_init();
|
| 253 |
+
curl_setopt($c, CURLOPT_URL, $this->getServiceIsAvailableUrl());
|
| 254 |
+
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
|
| 255 |
+
curl_setopt($c, CURLOPT_HEADER, false);
|
| 256 |
+
try {
|
| 257 |
+
$output = curl_exec($c);
|
| 258 |
+
$serviceAvailable = (trim($output) == '[OK]') ? true : false;
|
| 259 |
+
} catch(Exception $e) {
|
| 260 |
+
Mage::logException($e);
|
| 261 |
+
$serviceAvailable = false;
|
| 262 |
+
}
|
| 263 |
+
curl_close($c);
|
| 264 |
+
return $serviceAvailable;
|
| 265 |
+
}
|
| 266 |
+
}
|
app/code/community/LaPoste/SoColissimoSimplicite/Model/Carrier/ShippingMethod.php
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* @category LaPoste
|
| 16 |
+
* @package LaPoste_SoColissimoSimplicite
|
| 17 |
+
* @copyright Copyright (c) 2010 La Poste
|
| 18 |
+
* @author Smile (http://www.smile.fr)
|
| 19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 20 |
+
*/
|
| 21 |
+
/**
|
| 22 |
+
*
|
| 23 |
+
* Mode de livraison SO Colissimo Simplicité
|
| 24 |
+
*/
|
| 25 |
+
class LaPoste_SoColissimoSimplicite_Model_Carrier_ShippingMethod
|
| 26 |
+
extends Mage_Shipping_Model_Carrier_Abstract
|
| 27 |
+
implements Mage_Shipping_Model_Carrier_Interface
|
| 28 |
+
{
|
| 29 |
+
/**
|
| 30 |
+
* Identifiant unique du mode de livraison
|
| 31 |
+
* @var string
|
| 32 |
+
*/
|
| 33 |
+
protected $_code = 'socolissimosimplicite';
|
| 34 |
+
|
| 35 |
+
/**
|
| 36 |
+
* Récolte et retourne les informations sur le mode de livraison utiles
|
| 37 |
+
* pour le passage d'une commande.
|
| 38 |
+
* @param Mage_Shipping_Model_Rate_Request $request
|
| 39 |
+
* @return Mage_Shipping_Model_Rate_Result
|
| 40 |
+
*/
|
| 41 |
+
public function collectRates(Mage_Shipping_Model_Rate_Request $request) {
|
| 42 |
+
|
| 43 |
+
//on stoppe si le mode de livraison n'est pas activé dans la configuration
|
| 44 |
+
if (!$this->getConfigFlag('active')) {
|
| 45 |
+
return false;
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
$result = Mage::getModel('shipping/rate_result');
|
| 49 |
+
$method = Mage::getModel('shipping/rate_result_method');
|
| 50 |
+
|
| 51 |
+
$method->setCarrier($this->_code);
|
| 52 |
+
$method->setCarrierTitle($this->getConfigData('title'));
|
| 53 |
+
|
| 54 |
+
$method->setMethod($this->_code);
|
| 55 |
+
$method->setMethodTitle($this->getConfigData('name'));
|
| 56 |
+
|
| 57 |
+
// vérifier si la livraison collisimo est offerte et à partir de quel montant
|
| 58 |
+
$minQuotePriceForFreeShipping = $this->getConfigData('minquotepriceforfree');
|
| 59 |
+
$quotePriceWithDiscount = $request->getData('package_value_with_discount');
|
| 60 |
+
if ($minQuotePriceForFreeShipping > 0 and $quotePriceWithDiscount >= $minQuotePriceForFreeShipping) {
|
| 61 |
+
$method->setPrice(0);
|
| 62 |
+
} else {
|
| 63 |
+
$method->setPrice($this->getCalculatedPrice());
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
$result->append($method);
|
| 67 |
+
|
| 68 |
+
return $result;
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
/**
|
| 72 |
+
* Retourne les modes de livraison authorisés.
|
| 73 |
+
* @return array
|
| 74 |
+
*/
|
| 75 |
+
public function getAllowedMethods()
|
| 76 |
+
{
|
| 77 |
+
return array($this->_code => $this->getConfigData('name'));
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
/**
|
| 81 |
+
* Retourne le montant des frais de livraison après éventuels calculs
|
| 82 |
+
* selon le mode de tarification choisi dans l'administration.
|
| 83 |
+
* @return float
|
| 84 |
+
*/
|
| 85 |
+
public function getCalculatedPrice()
|
| 86 |
+
{
|
| 87 |
+
$amountBaseType = $this->getConfigData('amountbasetype');
|
| 88 |
+
$amountCalculation = $this->getConfigData('amountcalculation');
|
| 89 |
+
$helper = Mage::helper('socolissimosimplicite');
|
| 90 |
+
switch ($amountBaseType) {
|
| 91 |
+
case 'fixed':
|
| 92 |
+
if (is_numeric($amountCalculation)) {
|
| 93 |
+
$calculatedPrice = $amountCalculation;
|
| 94 |
+
} else {
|
| 95 |
+
throw new Exception($helper->__('SoColissimo : la valeur de configuration "Calcul des frais de livraison" fournie "'.$amountCalculation.'" doit être un numérique de la forme 5.50'));
|
| 96 |
+
}
|
| 97 |
+
break;
|
| 98 |
+
case 'per_weight':
|
| 99 |
+
$rules = json_decode($amountCalculation, true);
|
| 100 |
+
// si vide
|
| 101 |
+
if (is_null($rules) or empty($rules)) {
|
| 102 |
+
throw new Exception($helper->__('SoColissimo : la valeur de configuration "Calcul des frais de livraison" pour le type "tarif selon le poids" fournie "'.$amountCalculation.'" n\'est pas dans le bon format, exemple {"0":"2.90","0.5":"4.50","5":"8","10":"14"}'));
|
| 103 |
+
} else {
|
| 104 |
+
try {
|
| 105 |
+
//tri par poids décroissant
|
| 106 |
+
krsort($rules,SORT_NUMERIC);
|
| 107 |
+
|
| 108 |
+
//récupération du poids total de la commande (en kilogrammes)
|
| 109 |
+
$shippingAddress = Mage::getModel('checkout/cart')
|
| 110 |
+
->getQuote()->getShippingAddress();
|
| 111 |
+
$totalWeight = $shippingAddress->getWeight();
|
| 112 |
+
|
| 113 |
+
//recherche du prix selon les fourchettes de tarifs données
|
| 114 |
+
$calculatedPrice = false;
|
| 115 |
+
foreach ($rules as $w => $p) {
|
| 116 |
+
if ($calculatedPrice === false) {
|
| 117 |
+
$calculatedPrice = $p;
|
| 118 |
+
}
|
| 119 |
+
$calculatedPrice = $p;
|
| 120 |
+
if ($w < $totalWeight) {
|
| 121 |
+
break;
|
| 122 |
+
}
|
| 123 |
+
}
|
| 124 |
+
} catch (Exception $e) {
|
| 125 |
+
throw new Exception($helper->__('SoColissimo : la valeur de configuration "Calcul des frais de livraison" pour le type "tarif selon le poids" fournie "'.$amountCalculation.'" n\'est pas dans le bon format, exemple {"0":"2.90","0.5":"4.50","5":"8","10":"14"}'));
|
| 126 |
+
}
|
| 127 |
+
}
|
| 128 |
+
break;
|
| 129 |
+
default:
|
| 130 |
+
throw new Exception($helper->__('SoColissimo : la valeur de configuration "Type des frais de livraison" fourni "'.$amountBaseType.'" n\'est pas disponible'));
|
| 131 |
+
break;
|
| 132 |
+
}
|
| 133 |
+
return $calculatedPrice;
|
| 134 |
+
}
|
| 135 |
+
}
|
app/code/community/LaPoste/SoColissimoSimplicite/Model/Mysql4/Transaction.php
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* @category LaPoste
|
| 16 |
+
* @package LaPoste_SoColissimoSimplicite
|
| 17 |
+
* @copyright Copyright (c) 2010 La Poste
|
| 18 |
+
* @author Smile (http://www.smile.fr)
|
| 19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 20 |
+
*/
|
| 21 |
+
/**
|
| 22 |
+
*
|
| 23 |
+
* Transaction entre Magento et SO Colissimo
|
| 24 |
+
*/
|
| 25 |
+
class LaPoste_SoColissimoSimplicite_Model_Mysql4_Transaction extends Mage_Core_Model_Mysql4_Abstract
|
| 26 |
+
{
|
| 27 |
+
public function _construct() {
|
| 28 |
+
$this->_init('socolissimosimplicite/transaction','transaction_id');
|
| 29 |
+
}
|
| 30 |
+
}
|
app/code/community/LaPoste/SoColissimoSimplicite/Model/Mysql4/Transaction/Collection.php
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* @category LaPoste
|
| 16 |
+
* @package LaPoste_SoColissimoSimplicite
|
| 17 |
+
* @copyright Copyright (c) 2010 La Poste
|
| 18 |
+
* @author Smile (http://www.smile.fr)
|
| 19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 20 |
+
*/
|
| 21 |
+
/**
|
| 22 |
+
*
|
| 23 |
+
* Collection des transactions entre Magento et SO Colissimo
|
| 24 |
+
*/
|
| 25 |
+
class LaPoste_SoColissimoSimplicite_Model_Mysql4_Transaction_Collection
|
| 26 |
+
extends Mage_Core_Model_Mysql4_Collection_Abstract
|
| 27 |
+
{
|
| 28 |
+
public function _construct() {
|
| 29 |
+
$this->_init('socolissimosimplicite/transaction');
|
| 30 |
+
}
|
| 31 |
+
}
|
app/code/community/LaPoste/SoColissimoSimplicite/Model/Observer.php
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* @category LaPoste
|
| 16 |
+
* @package LaPoste_SoColissimoSimplicite
|
| 17 |
+
* @copyright Copyright (c) 2010 La Poste
|
| 18 |
+
* @author Smile (http://www.smile.fr)
|
| 19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 20 |
+
*/
|
| 21 |
+
/**
|
| 22 |
+
*
|
| 23 |
+
* Observer SO Colissimo
|
| 24 |
+
*/
|
| 25 |
+
class LaPoste_SoColissimoSimplicite_Model_Observer
|
| 26 |
+
{
|
| 27 |
+
/**
|
| 28 |
+
* Tableau de correspondance les champs simples retournés par SO COlissimo
|
| 29 |
+
* et les champs d'une adresse de livraison dans Magento.
|
| 30 |
+
* @var array
|
| 31 |
+
*/
|
| 32 |
+
protected $_mapFields = array (
|
| 33 |
+
'CENAME' => 'lastname',
|
| 34 |
+
'CEFIRSTNAME' => 'firstname',
|
| 35 |
+
'CETOWN' => 'city',
|
| 36 |
+
'CEZIPCODE' => 'postcode',
|
| 37 |
+
'CEEMAIL' => 'email',
|
| 38 |
+
'CEPHONENUMBER' => 'telephone',
|
| 39 |
+
'CECOMPANYNAME' => 'company',
|
| 40 |
+
'DYFORWARDINGCHARGES' => 'shippingAmount',
|
| 41 |
+
'PRZIPCODE' => 'postcode',
|
| 42 |
+
'PRTOWN' => 'city'
|
| 43 |
+
);
|
| 44 |
+
|
| 45 |
+
/**
|
| 46 |
+
* Met à jour les données de livraison à partir des infos récupérées depuis
|
| 47 |
+
* SO Colissimo.
|
| 48 |
+
* L'adresse de livraison est automatiquement réinitialisée avec celle par défaut
|
| 49 |
+
* du client dès qu'il est sur le tunnel de commande, c'est pourquoi cette mise
|
| 50 |
+
* a jour est effectué APRÈS cette réinitialisation.
|
| 51 |
+
* @param Varien_Event_Observer $observer
|
| 52 |
+
*/
|
| 53 |
+
public function setShippingAddressWithSoColissimoAddress($observer)
|
| 54 |
+
{
|
| 55 |
+
$checkoutSession = Mage::getSingleton('checkout/session');
|
| 56 |
+
|
| 57 |
+
$transactionId = $checkoutSession->getData('socolissimosimplicite_checkout_onepage_transactionid');
|
| 58 |
+
$nextStep = $checkoutSession->getData('socolissimosimplicite_checkout_onepage_nextstep');
|
| 59 |
+
|
| 60 |
+
//on regarde s'il existe une transaction avec SO Colissimo en session et si on cherche à afficher
|
| 61 |
+
//le choix du mode de paiement
|
| 62 |
+
if ($transactionId && $nextStep == 'payment') {
|
| 63 |
+
|
| 64 |
+
//on regarde s'il s'agit d'une adresse de livraison
|
| 65 |
+
$shippingAddress = Mage::getModel('checkout/cart')
|
| 66 |
+
->getQuote()->getShippingAddress();
|
| 67 |
+
|
| 68 |
+
if ($shippingAddress) {
|
| 69 |
+
//les données de l'adresse de livraison sont réinitialisées avec l'adresse par défaut
|
| 70 |
+
//du client automatiquement lorsque l'on est sur le tunnel de commande,
|
| 71 |
+
//il faut donc mettre à jour les informations de livraison récupérées
|
| 72 |
+
//depuis SO Colissimo
|
| 73 |
+
$shippingData = $checkoutSession->getData('socolissimosimplicite_shipping_data');
|
| 74 |
+
|
| 75 |
+
$this->_updateQuoteAndShippingAddress($shippingAddress,$shippingData);
|
| 76 |
+
}
|
| 77 |
+
}
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
public function clearCheckoutSession($observer)
|
| 81 |
+
{
|
| 82 |
+
$checkoutSession = Mage::getSingleton('checkout/session');
|
| 83 |
+
|
| 84 |
+
if ($checkoutSession) {
|
| 85 |
+
$checkoutSession->unsetData('socolissimosimplicite_checkout_onepage_nextstep');
|
| 86 |
+
$checkoutSession->unsetData('socolissimosimplicite_checkout_onepage_transactionid');
|
| 87 |
+
$checkoutSession->unsetData('socolissimosimplicite_shipping_data');
|
| 88 |
+
$checkoutSession->unsetData('socolissimosimplicite_from_socolissimo');
|
| 89 |
+
$checkoutSession->unsetData('socolissimosimplicite_new_address_from_socolissimo');
|
| 90 |
+
}
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
/**
|
| 94 |
+
* Met à jour les données sur l'adresse de livraison à partir des
|
| 95 |
+
* informations retournées par SO Colissimo.
|
| 96 |
+
* @param Mage_Sales_Model_Quote_Address $shippingAddress
|
| 97 |
+
* @param array $shippingData
|
| 98 |
+
* @todo replace this cause it's executed at each request !
|
| 99 |
+
*/
|
| 100 |
+
protected function _updateQuoteAndShippingAddress($shippingAddress, $shippingData)
|
| 101 |
+
{
|
| 102 |
+
$checkoutSession = Mage::getSingleton('checkout/session');
|
| 103 |
+
if ($checkoutSession->hasData('socolissimosimplicite_new_address_from_socolissimo')) {
|
| 104 |
+
|
| 105 |
+
// on traite la nouvelle addresse une seule fois
|
| 106 |
+
$checkoutSession->unsetData('socolissimosimplicite_new_address_from_socolissimo');
|
| 107 |
+
|
| 108 |
+
$helper = Mage::helper('socolissimosimplicite');
|
| 109 |
+
|
| 110 |
+
$arrayData = array();
|
| 111 |
+
$arrayData['customer_address_id'] = null;
|
| 112 |
+
|
| 113 |
+
$street = array();
|
| 114 |
+
$customerNotesArray = array();
|
| 115 |
+
|
| 116 |
+
foreach ($shippingData as $fieldSoCo => $valueSoCo) {
|
| 117 |
+
if (array_key_exists($fieldSoCo,$this->_mapFields)) {
|
| 118 |
+
$fieldMagento = $this->_mapFields[$fieldSoCo];
|
| 119 |
+
$arrayData[$fieldMagento] = $valueSoCo;
|
| 120 |
+
} elseif ($valueSoCo) {
|
| 121 |
+
switch ($fieldSoCo) {
|
| 122 |
+
case 'CECIVILITY':
|
| 123 |
+
$arrayData['prefix'] = $helper->getPrefixForMagento($shippingData[$fieldSoCo]);
|
| 124 |
+
break;
|
| 125 |
+
|
| 126 |
+
//cas particulier des informations de rue, complément d'adresse etc.
|
| 127 |
+
|
| 128 |
+
//cas livraison à domicile
|
| 129 |
+
case 'CEADRESS3':
|
| 130 |
+
$street['0'] = $shippingData[$fieldSoCo]; //mis en 1er car numéro de rue obligatoire côté SoCo
|
| 131 |
+
break;
|
| 132 |
+
case 'CEADRESS1':
|
| 133 |
+
$street['1'] = $shippingData[$fieldSoCo];
|
| 134 |
+
break;
|
| 135 |
+
case 'CEADRESS2':
|
| 136 |
+
$street['2'] = $shippingData[$fieldSoCo];
|
| 137 |
+
break;
|
| 138 |
+
case 'CEADRESS4':
|
| 139 |
+
$street['3'] = $shippingData[$fieldSoCo];
|
| 140 |
+
break;
|
| 141 |
+
|
| 142 |
+
//cas livraison en point relai
|
| 143 |
+
case 'PRNAME':
|
| 144 |
+
$street['0'] = $shippingData[$fieldSoCo];
|
| 145 |
+
break;
|
| 146 |
+
case 'PRCOMPLADRESS':
|
| 147 |
+
$street['1'] = $shippingData[$fieldSoCo];
|
| 148 |
+
break;
|
| 149 |
+
case 'PRADRESS1':
|
| 150 |
+
$street['2'] = $shippingData[$fieldSoCo];
|
| 151 |
+
break;
|
| 152 |
+
case 'PRADRESS2':
|
| 153 |
+
$street['3'] = $shippingData[$fieldSoCo];
|
| 154 |
+
break;
|
| 155 |
+
|
| 156 |
+
//autres informations sur la livraison
|
| 157 |
+
case 'CEENTRYPHONE':
|
| 158 |
+
$customerNotesArray['0'] = $helper->__('Interphone').' : '.$shippingData[$fieldSoCo];
|
| 159 |
+
break;
|
| 160 |
+
case 'CEDOORCODE1':
|
| 161 |
+
$customerNotesArray['1'] = $helper->__('Code porte').' : '.$shippingData[$fieldSoCo];
|
| 162 |
+
break;
|
| 163 |
+
case 'CEDOORCODE2':
|
| 164 |
+
$customerNotesArray['2'] = $helper->__('Code porte 2').' : '.$shippingData[$fieldSoCo];
|
| 165 |
+
break;
|
| 166 |
+
case 'CEDELIVERYINFORMATION':
|
| 167 |
+
$customerNotesArray['3'] = $shippingData[$fieldSoCo];
|
| 168 |
+
break;
|
| 169 |
+
|
| 170 |
+
default:
|
| 171 |
+
break;
|
| 172 |
+
}
|
| 173 |
+
}
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
if (! empty($customerNotesArray)) {
|
| 177 |
+
$arrayData['customer_notes'] = implode("\n",$customerNotesArray);
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
// sauvegarde dans le carnet d'adresse seulement pour les modes domicile ou rendez-vous
|
| 181 |
+
$deliveryMode = isset($shippingData['DELIVERYMODE'])? $shippingData['DELIVERYMODE'] : null;
|
| 182 |
+
if ($deliveryMode != 'DOM' and $deliveryMode != 'RDV') {
|
| 183 |
+
$arrayData['save_in_address_book'] = 0;
|
| 184 |
+
}
|
| 185 |
+
|
| 186 |
+
// sauvegarder l'adresse
|
| 187 |
+
$shippingAddress->addData($arrayData);
|
| 188 |
+
$shippingAddress->setStreet($street);
|
| 189 |
+
$shippingAddress->save();
|
| 190 |
+
}
|
| 191 |
+
}
|
| 192 |
+
}
|
app/code/community/LaPoste/SoColissimoSimplicite/Model/System/Config/Source/Shipping/Amountbasetype.php
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category LaPoste
|
| 22 |
+
* @package LaPoste_SoColissimoSimplicite
|
| 23 |
+
* @copyright Copyright (c) 2010 La Poste
|
| 24 |
+
* @author Smile (http://www.smile.fr)
|
| 25 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 26 |
+
*/
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
class LaPoste_SoColissimoSimplicite_Model_System_Config_Source_Shipping_Amountbasetype
|
| 30 |
+
{
|
| 31 |
+
public function toOptionArray()
|
| 32 |
+
{
|
| 33 |
+
return array(
|
| 34 |
+
array(
|
| 35 |
+
'value'=>'fixed',
|
| 36 |
+
'label'=>Mage::helper('socolissimosimplicite')->__('Tarif unique')),
|
| 37 |
+
array(
|
| 38 |
+
'value'=>'per_weight',
|
| 39 |
+
'label'=>Mage::helper('socolissimosimplicite')->__('Tarif selon poids')),
|
| 40 |
+
);
|
| 41 |
+
}
|
| 42 |
+
}
|
app/code/community/LaPoste/SoColissimoSimplicite/Model/Transaction.php
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* @category LaPoste
|
| 16 |
+
* @package LaPoste_SoColissimoSimplicite
|
| 17 |
+
* @copyright Copyright (c) 2010 La Poste
|
| 18 |
+
* @author Smile (http://www.smile.fr)
|
| 19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 20 |
+
*/
|
| 21 |
+
/**
|
| 22 |
+
*
|
| 23 |
+
* Transaction entre Magento et SO Colissimo
|
| 24 |
+
*/
|
| 25 |
+
class LaPoste_SoColissimoSimplicite_Model_Transaction extends Mage_Core_Model_Abstract
|
| 26 |
+
{
|
| 27 |
+
protected $_helper;
|
| 28 |
+
|
| 29 |
+
/**
|
| 30 |
+
* Constructeur par défaut
|
| 31 |
+
* @return LaPoste_SoColissimoSimplicite_Model_Transaction
|
| 32 |
+
*/
|
| 33 |
+
public function _construct() {
|
| 34 |
+
parent::_construct();
|
| 35 |
+
$this->_init('socolissimosimplicite/transaction');
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
/**
|
| 39 |
+
* Retourne le helper principal du module.
|
| 40 |
+
* @return LaPoste_SoColissimoSimplicite_Helper_Data
|
| 41 |
+
*/
|
| 42 |
+
public function helper() {
|
| 43 |
+
if (is_null($this->_helper)) {
|
| 44 |
+
$this->_helper = Mage::helper('socolissimosimplicite');
|
| 45 |
+
}
|
| 46 |
+
return $this->_helper;
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
/**
|
| 50 |
+
* Crée et sauvegarde les données de la transaction avec SO Colissimo
|
| 51 |
+
* (avant l'accès à la plateforme).
|
| 52 |
+
* @param Mage_Sales_Model_Quote_Address $shippingAddress
|
| 53 |
+
* @return LaPoste_SoColissimoSimplicite_Model_Transaction
|
| 54 |
+
*/
|
| 55 |
+
public function create($shippingAddress) {
|
| 56 |
+
|
| 57 |
+
$now = date('Y-m-d h:i:s');
|
| 58 |
+
$this->setCreatedAt($now);
|
| 59 |
+
$this->setIsDone(0);
|
| 60 |
+
|
| 61 |
+
try {
|
| 62 |
+
$this->setQuoteId($shippingAddress->getQuoteId());
|
| 63 |
+
$this->save(); //1ère sauvegarde pour récupérer le transaction_id pour la signature
|
| 64 |
+
|
| 65 |
+
$this->setSignature($this->_getGeneratedSignature($shippingAddress));
|
| 66 |
+
$this->save();
|
| 67 |
+
|
| 68 |
+
} catch (Exception $e) {
|
| 69 |
+
throw new Exception($e);
|
| 70 |
+
}
|
| 71 |
+
return $this;
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
/**
|
| 75 |
+
* Génère la signature requise pour l'accès à la plateforme SO Colissimo (front-office).
|
| 76 |
+
*
|
| 77 |
+
* SPECIFICATIONS FOURNIES PAR LA POSTE :
|
| 78 |
+
*
|
| 79 |
+
* La signature permet de garantir que les données transmises à la Page SO
|
| 80 |
+
* « Modes de livraison » ne subiront pas de modifications ultérieures.
|
| 81 |
+
*
|
| 82 |
+
* La signature permet un contrôle de l’accès à la page SO « Modes de livraison ».
|
| 83 |
+
*
|
| 84 |
+
* La signature doit être :
|
| 85 |
+
* - renseignée
|
| 86 |
+
* - correspondre à celle calculée par La Poste ColiPoste (à noter que celle-ci doit
|
| 87 |
+
* être calculée en minuscule)
|
| 88 |
+
*
|
| 89 |
+
* Si ce n’est pas le cas, l’accès à la Page SO « Modes de livraison » ne sera pas
|
| 90 |
+
* autorisé. L’internaute sera redirigé vers l'url retour Echec. Un code erreur sera
|
| 91 |
+
* transmis.
|
| 92 |
+
*
|
| 93 |
+
* Il s’agit d’appliquer l’algorithme SHA sur la concaténation des champs suivants :
|
| 94 |
+
* Champ pour la signature | Nom du champ | Obligatoire
|
| 95 |
+
* ---------------------------------+---------------------+-------------
|
| 96 |
+
* Identifiant | FO pudoFOId | Oui
|
| 97 |
+
* Nom du destinataire | ceName | Non
|
| 98 |
+
* Délai de préparation de commande | dyPreparationTime | Non
|
| 99 |
+
* Frais d’expédition | dyForwardingCharges | Oui
|
| 100 |
+
* N° client web | trClientNumber | Non
|
| 101 |
+
* N° commande | trOrderNumber | Non
|
| 102 |
+
* N° transaction | orderId | Oui
|
| 103 |
+
*
|
| 104 |
+
* La clé SHA doit être également concaténée à la fin de la chaîne :
|
| 105 |
+
* Chaîne_à_convertir= pudoFOId+ceName+ dyPreparationTime+
|
| 106 |
+
* dyForwardingCharges+ trClientNumber+ trOrderNumber+ orderId+cléSHA
|
| 107 |
+
* Signature=SHA1(Chaîne_à_convertir)
|
| 108 |
+
*
|
| 109 |
+
* Certains des champs ci-dessus ne sont pas obligatoires. S’ils ne sont pas transmis
|
| 110 |
+
* par le site web, ils ne doivent pas être pris en compte dans le calcul de la
|
| 111 |
+
* signature.
|
| 112 |
+
* FIN SPECIFICATIONS
|
| 113 |
+
*
|
| 114 |
+
* @param LaPoste_SoColissimoSimplicite_Model_Carrier_ShippingMethod $method
|
| 115 |
+
* @param Mage_Sales_Model_Quote_Address $shippingAddress
|
| 116 |
+
* @todo when signature is calculated with strtolower($stringToConvert),
|
| 117 |
+
* access to colissimo is forbidden (error code 007 signature invalide)
|
| 118 |
+
* @return string signature de 160 bits (40 caractères)
|
| 119 |
+
*/
|
| 120 |
+
protected function _getGeneratedSignature($shippingAddress) {
|
| 121 |
+
|
| 122 |
+
$stringToConvert = '';
|
| 123 |
+
|
| 124 |
+
if ($this->getId() && ! is_null($shippingAddress)) {
|
| 125 |
+
$accountId = $this->helper()->getAccountId();
|
| 126 |
+
$encryptionKey = $this->helper()->getEncryptionKey();
|
| 127 |
+
|
| 128 |
+
$stringToConvert =
|
| 129 |
+
$accountId.
|
| 130 |
+
$shippingAddress->getLastname().
|
| 131 |
+
$this->helper()->getFormatedShippingPrice($shippingAddress->getShippingAmount()).
|
| 132 |
+
$shippingAddress->getCustomerId().
|
| 133 |
+
$shippingAddress->getQuoteId().
|
| 134 |
+
$this->getId().
|
| 135 |
+
$encryptionKey;
|
| 136 |
+
}
|
| 137 |
+
return sha1($stringToConvert);
|
| 138 |
+
}
|
| 139 |
+
}
|
app/code/community/LaPoste/SoColissimoSimplicite/controllers/FormController.php
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* @category LaPoste
|
| 16 |
+
* @package LaPoste_SoColissimoSimplicite
|
| 17 |
+
* @copyright Copyright (c) 2010 La Poste
|
| 18 |
+
* @author Smile (http://www.smile.fr)
|
| 19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 20 |
+
*/
|
| 21 |
+
/**
|
| 22 |
+
* Contrôleur pour les échanges avec l'interface SO Colissimo en front office.
|
| 23 |
+
*/
|
| 24 |
+
class LaPoste_SoColissimoSimplicite_FormController extends Mage_Core_Controller_Front_Action
|
| 25 |
+
{
|
| 26 |
+
/**
|
| 27 |
+
* Soumet le formulaire pour l'accès à SO Colissimo
|
| 28 |
+
* @todo check postal code and country before send (only France, Monaco et Andorre)
|
| 29 |
+
*/
|
| 30 |
+
public function sendAction()
|
| 31 |
+
{
|
| 32 |
+
$checkoutSession = Mage::getSingleton('checkout/session');
|
| 33 |
+
|
| 34 |
+
// vérifier la disponibilité de la plateforme, si ce n'est pas le cas,
|
| 35 |
+
// sélectionner la livraison à domicile et passer à l'étape suivante
|
| 36 |
+
$helper = Mage::helper('socolissimosimplicite');
|
| 37 |
+
if ($helper->getServiceIsAvailable() and $helper->getServiceIsAvailableUrl() != '') {
|
| 38 |
+
$serviceAvailable = $helper->checkServiceAvailability();
|
| 39 |
+
// passer à l'étape suivante avec le mode livraison à domicile
|
| 40 |
+
if (!$serviceAvailable) {
|
| 41 |
+
$checkoutSession->setData('socolissimosimplicite_checkout_onepage_nextstep','payment');
|
| 42 |
+
$this->getResponse()->setRedirect(Mage::getUrl('checkout/onepage'));
|
| 43 |
+
return;
|
| 44 |
+
}
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
// utiliser un flag en session pour vérifier si l'on accède à l'action suite
|
| 48 |
+
// à un retour du site collissimo, si c'est le cas on redirige sur le checkout
|
| 49 |
+
if ($checkoutSession->hasData('socolissimosimplicite_from_socolissimo')) {
|
| 50 |
+
$checkoutSession->unsetData('socolissimosimplicite_from_socolissimo');
|
| 51 |
+
// sauvegarde de l'étape suivante en session (choix de la méthode de livraison)
|
| 52 |
+
$checkoutSession->setData('socolissimosimplicite_checkout_onepage_nextstep','shipping_method');
|
| 53 |
+
$this->getResponse()->setRedirect(Mage::getUrl('checkout/onepage'));
|
| 54 |
+
return;
|
| 55 |
+
} else {
|
| 56 |
+
$checkoutSession->setData('socolissimosimplicite_from_socolissimo', true);
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
//récupération de l'adresse de livraison de la commande en cours
|
| 60 |
+
$shippingAddress = $this->getShippingAddress();
|
| 61 |
+
|
| 62 |
+
//création d'une nouvelle transaction à partir de l'adresse de livraison.
|
| 63 |
+
$transaction = Mage::getModel('socolissimosimplicite/transaction')
|
| 64 |
+
->create($shippingAddress);
|
| 65 |
+
$checkoutSession->setData('socolissimosimplicite_checkout_onepage_transactionid', $transaction->getId());
|
| 66 |
+
|
| 67 |
+
$this->loadLayout();
|
| 68 |
+
|
| 69 |
+
//passage de données à la vue
|
| 70 |
+
$this->getLayout()->getBlock('form.socolissimosimplicite')
|
| 71 |
+
->setShippingAddress($shippingAddress)
|
| 72 |
+
->setTransaction($transaction);
|
| 73 |
+
|
| 74 |
+
$this->renderLayout();
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
/**
|
| 78 |
+
* Succès suite au retour de SO Colissimo
|
| 79 |
+
* @todo use TRPARAMPLUS to pass / get "payment" ?
|
| 80 |
+
* @todo deal with "error code" on validation (data truncation and others)
|
| 81 |
+
*/
|
| 82 |
+
public function successAction()
|
| 83 |
+
{
|
| 84 |
+
// permettre de revenir en arrière pour change le mode de livraison
|
| 85 |
+
$checkoutSession = Mage::getSingleton('checkout/session');
|
| 86 |
+
$checkoutSession->unsetData('socolissimosimplicite_from_socolissimo');
|
| 87 |
+
|
| 88 |
+
// si l'adresse de livraison a changée, mettre à jour la signature
|
| 89 |
+
$this->_updateSignature();
|
| 90 |
+
|
| 91 |
+
// sauvegarde des données retournées par SO Colissimo en session (choix du mode de paiement)
|
| 92 |
+
$this->_saveSoColissimoData($checkoutSession);
|
| 93 |
+
|
| 94 |
+
// sauvegarde de l'étape suivante en session
|
| 95 |
+
$checkoutSession->setData('socolissimosimplicite_checkout_onepage_nextstep','payment');
|
| 96 |
+
|
| 97 |
+
$this->getResponse()->setRedirect(Mage::getUrl('checkout/onepage'));
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
/**
|
| 101 |
+
* Échec lors de la soumission du formulaire d'accès à SO Colissimo
|
| 102 |
+
*/
|
| 103 |
+
public function failureAction()
|
| 104 |
+
{
|
| 105 |
+
// permettre de revenir en arrière pour change le mode de livraison
|
| 106 |
+
$checkoutSession = Mage::getSingleton('checkout/session');
|
| 107 |
+
$checkoutSession->unsetData('socolissimosimplicite_from_socolissimo');
|
| 108 |
+
|
| 109 |
+
// sauvegarde de l'étape suivante en session (choix de la méthode de livraison)
|
| 110 |
+
$checkoutSession->setData('socolissimosimplicite_checkout_onepage_nextstep','shipping_method');
|
| 111 |
+
|
| 112 |
+
// récupérer le code erreur et afficher le message correspondant
|
| 113 |
+
$errCode = trim($this->getRequest()->getPost('ERRORCODE'));
|
| 114 |
+
$helper = Mage::helper('socolissimosimplicite');
|
| 115 |
+
$errCodeToLabel = array(
|
| 116 |
+
'001' => $helper->__('Identifiant FO manquant'),
|
| 117 |
+
'002' => $helper->__('Identifiant FO incorrect'),
|
| 118 |
+
'003' => $helper->__('Client non autorisé'),
|
| 119 |
+
'004' => $helper->__('Champs obligatoire manquant'),
|
| 120 |
+
'006' => $helper->__('Signature manquante'),
|
| 121 |
+
'007' => $helper->__('Signature invalide'),
|
| 122 |
+
'008' => $helper->__('Code postal invalide'),
|
| 123 |
+
'009' => $helper->__('Format url retour Validation incorrect'),
|
| 124 |
+
'010' => $helper->__('Format url retour Echec incorrect'),
|
| 125 |
+
'011' => $helper->__('Numéro de transaction non valide'),
|
| 126 |
+
'012' => $helper->__('Format des frais d’expédition incorrect'),
|
| 127 |
+
'015' => $helper->__('Serveur applicatif non disponible'),
|
| 128 |
+
'016' => $helper->__('SGBD non disponible')
|
| 129 |
+
);
|
| 130 |
+
// add error message on checkout
|
| 131 |
+
if (array_key_exists($errCode, $errCodeToLabel)) {
|
| 132 |
+
$msg = $errCodeToLabel[$errCode];
|
| 133 |
+
} else {
|
| 134 |
+
$msg = $helper->__('Erreur non identifiée');
|
| 135 |
+
}
|
| 136 |
+
$checkoutSession->addError($msg);
|
| 137 |
+
$this->_redirect('checkout/cart');
|
| 138 |
+
return;
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
/**
|
| 142 |
+
* Retourne l'adresse de livraison de la commande en cours.
|
| 143 |
+
* @todo to deal with session lost
|
| 144 |
+
* @return Mage_Sales_Model_Quote_Address
|
| 145 |
+
*/
|
| 146 |
+
public function getShippingAddress($quoteId = false)
|
| 147 |
+
{
|
| 148 |
+
$shippingAddress = Mage::getModel('checkout/cart')
|
| 149 |
+
->getQuote()->getShippingAddress();
|
| 150 |
+
return $shippingAddress;
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
/**
|
| 154 |
+
* Vérifie si la signature a changée (ie l'adresse de livraison a changée),
|
| 155 |
+
* dans ce cas mettre à jour la signature
|
| 156 |
+
*/
|
| 157 |
+
protected function _updateSignature()
|
| 158 |
+
{
|
| 159 |
+
$newSignature = $this->getRequest()->getParam('SIGNATURE');
|
| 160 |
+
// signature invalide
|
| 161 |
+
if (empty($newSignature)) {
|
| 162 |
+
throw new Exception(Mage::helper('socolissimosimplicite')->__("SoColissimo : la signature retournée par colissimo est vide"));
|
| 163 |
+
}
|
| 164 |
+
$transactionId = $this->getRequest()->getParam('ORDERID');
|
| 165 |
+
$transactions = Mage::getModel('socolissimosimplicite/transaction')
|
| 166 |
+
->getCollection()
|
| 167 |
+
->addFieldToFilter('transaction_id', $transactionId);
|
| 168 |
+
// transaction inexistante
|
| 169 |
+
if ($transactions->getSize() == 0) {
|
| 170 |
+
throw new Exception(Mage::helper('socolissimosimplicite')->__("SoColissimo : la transaction avec colissimo (id=".$transactionId.") n'est pas valide car inconnue de Magento"));
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
// mettre à jour la signature si elle a changée
|
| 174 |
+
$transaction = current(array_values($transactions->getItems()));
|
| 175 |
+
if ($transaction->getSignature() != $newSignature) {
|
| 176 |
+
$transaction->setSignature($newSignature);
|
| 177 |
+
$transaction->save();
|
| 178 |
+
}
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
/**
|
| 182 |
+
* Enregistre les données retournées par SO Colissimo en session,
|
| 183 |
+
* afin de mettre à jour les données de livraison ultérieurement.
|
| 184 |
+
* @param Mage_Checkout_Model_Session $checkoutSession
|
| 185 |
+
*/
|
| 186 |
+
protected function _saveSoColissimoData($checkoutSession)
|
| 187 |
+
{
|
| 188 |
+
// sauve params adresse livraison
|
| 189 |
+
$allParams = $this->getRequest()->getParams();
|
| 190 |
+
$paramKeysToNotSave = array_flip(array(
|
| 191 |
+
'TRRETURNURLKO',
|
| 192 |
+
'PUDOFOID',
|
| 193 |
+
'TRPARAMPLUS',
|
| 194 |
+
'TRADERCOMPANYNAME',
|
| 195 |
+
'ORDERID',
|
| 196 |
+
'SIGNATURE',
|
| 197 |
+
));
|
| 198 |
+
$shippingData = array_diff_key($allParams,$paramKeysToNotSave);
|
| 199 |
+
$checkoutSession->setData('socolissimosimplicite_shipping_data', $shippingData);
|
| 200 |
+
|
| 201 |
+
// sauve transaction id, pour éviter de créer une nouvelle transaction si retour en arrière
|
| 202 |
+
$transactionId = $this->getRequest()->getParam('ORDERID');
|
| 203 |
+
$checkoutSession->setData('socolissimosimplicite_checkout_onepage_transactionid', $transactionId);
|
| 204 |
+
|
| 205 |
+
// indique que l'adresse vient de socolissimo
|
| 206 |
+
$checkoutSession->setData('socolissimosimplicite_new_address_from_socolissimo', true);
|
| 207 |
+
}
|
| 208 |
+
}
|
app/code/community/LaPoste/SoColissimoSimplicite/etc/config.xml
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<!--
|
| 3 |
+
/**
|
| 4 |
+
* Magento
|
| 5 |
+
*
|
| 6 |
+
* NOTICE OF LICENSE
|
| 7 |
+
*
|
| 8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 10 |
+
* It is also available through the world-wide-web at this URL:
|
| 11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 12 |
+
* If you did not receive a copy of the license and are unable to
|
| 13 |
+
* obtain it through the world-wide-web, please send an email
|
| 14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 15 |
+
*
|
| 16 |
+
* @category LaPoste
|
| 17 |
+
* @package LaPoste_SoColissimoSimplicite
|
| 18 |
+
* @copyright Copyright (c) 2010 La Poste
|
| 19 |
+
* @author Smile (http://www.smile.fr)
|
| 20 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 21 |
+
*/
|
| 22 |
+
-->
|
| 23 |
+
<config>
|
| 24 |
+
<modules>
|
| 25 |
+
<LaPoste_SoColissimoSimplicite>
|
| 26 |
+
<version>1.0.2</version>
|
| 27 |
+
</LaPoste_SoColissimoSimplicite>
|
| 28 |
+
</modules>
|
| 29 |
+
|
| 30 |
+
<global>
|
| 31 |
+
<blocks>
|
| 32 |
+
<socolissimosimplicite><class>LaPoste_SoColissimoSimplicite_Block</class></socolissimosimplicite>
|
| 33 |
+
</blocks>
|
| 34 |
+
|
| 35 |
+
<models>
|
| 36 |
+
<socolissimosimplicite>
|
| 37 |
+
<class>LaPoste_SoColissimoSimplicite_Model</class>
|
| 38 |
+
<resourceModel>socolissimosimplicite_mysql4</resourceModel>
|
| 39 |
+
</socolissimosimplicite>
|
| 40 |
+
|
| 41 |
+
<socolissimosimplicite_mysql4>
|
| 42 |
+
<class>LaPoste_SoColissimoSimplicite_Model_Mysql4</class>
|
| 43 |
+
<entities>
|
| 44 |
+
<transaction>
|
| 45 |
+
<table>laposte_socolissimosimplicite_transaction</table>
|
| 46 |
+
</transaction>
|
| 47 |
+
</entities>
|
| 48 |
+
</socolissimosimplicite_mysql4>
|
| 49 |
+
</models>
|
| 50 |
+
|
| 51 |
+
<helpers>
|
| 52 |
+
<socolissimosimplicite>
|
| 53 |
+
<class>LaPoste_SoColissimoSimplicite_Helper</class>
|
| 54 |
+
</socolissimosimplicite>
|
| 55 |
+
</helpers>
|
| 56 |
+
|
| 57 |
+
<resources>
|
| 58 |
+
<socolissimosimplicite_setup>
|
| 59 |
+
<setup>
|
| 60 |
+
<module>LaPoste_SoColissimoSimplicite</module>
|
| 61 |
+
</setup>
|
| 62 |
+
<connection>
|
| 63 |
+
<use>core_setup</use>
|
| 64 |
+
</connection>
|
| 65 |
+
</socolissimosimplicite_setup>
|
| 66 |
+
|
| 67 |
+
<socolissimosimplicite_read>
|
| 68 |
+
<connection>
|
| 69 |
+
<use>core_read</use>
|
| 70 |
+
</connection>
|
| 71 |
+
</socolissimosimplicite_read>
|
| 72 |
+
|
| 73 |
+
<socolissimosimplicite_write>
|
| 74 |
+
<connection>
|
| 75 |
+
<use>core_write</use>
|
| 76 |
+
</connection>
|
| 77 |
+
</socolissimosimplicite_write>
|
| 78 |
+
</resources>
|
| 79 |
+
|
| 80 |
+
<translate>
|
| 81 |
+
<modules>
|
| 82 |
+
<LaPoste_SoColissimoSimplicite>
|
| 83 |
+
<files>
|
| 84 |
+
<default>LaPoste_SoColissimoSimplicite.csv</default>
|
| 85 |
+
</files>
|
| 86 |
+
</LaPoste_SoColissimoSimplicite>
|
| 87 |
+
</modules>
|
| 88 |
+
</translate>
|
| 89 |
+
</global>
|
| 90 |
+
|
| 91 |
+
<frontend>
|
| 92 |
+
<layout>
|
| 93 |
+
<updates>
|
| 94 |
+
<socolissimosimplicite module="LaPoste_SoColissimoSimplicite">
|
| 95 |
+
<file>socolissimosimplicite.xml</file>
|
| 96 |
+
</socolissimosimplicite>
|
| 97 |
+
</updates>
|
| 98 |
+
</layout>
|
| 99 |
+
|
| 100 |
+
<routers>
|
| 101 |
+
<socolissimosimplicite>
|
| 102 |
+
<use>standard</use>
|
| 103 |
+
<args>
|
| 104 |
+
<module>LaPoste_SoColissimoSimplicite</module>
|
| 105 |
+
<frontName>socolissimosimplicite</frontName>
|
| 106 |
+
</args>
|
| 107 |
+
</socolissimosimplicite>
|
| 108 |
+
</routers>
|
| 109 |
+
|
| 110 |
+
<events>
|
| 111 |
+
<controller_action_layout_load_before>
|
| 112 |
+
<observers>
|
| 113 |
+
<laposte_socolissimosimplicite_observer>
|
| 114 |
+
<type>singleton</type>
|
| 115 |
+
<class>socolissimosimplicite/observer</class>
|
| 116 |
+
<method>setShippingAddressWithSoColissimoAddress</method>
|
| 117 |
+
</laposte_socolissimosimplicite_observer>
|
| 118 |
+
</observers>
|
| 119 |
+
</controller_action_layout_load_before>
|
| 120 |
+
<checkout_onepage_controller_success_action>
|
| 121 |
+
<observers>
|
| 122 |
+
<laposte_socolissimosimplicite_observer>
|
| 123 |
+
<type>singleton</type>
|
| 124 |
+
<class>socolissimosimplicite/observer</class>
|
| 125 |
+
<method>clearCheckoutSession</method>
|
| 126 |
+
</laposte_socolissimosimplicite_observer>
|
| 127 |
+
</observers>
|
| 128 |
+
</checkout_onepage_controller_success_action>
|
| 129 |
+
</events>
|
| 130 |
+
</frontend>
|
| 131 |
+
|
| 132 |
+
<default>
|
| 133 |
+
<carriers>
|
| 134 |
+
<socolissimosimplicite>
|
| 135 |
+
<active>0</active>
|
| 136 |
+
<title>La Poste</title>
|
| 137 |
+
<name>So Colissimo</name>
|
| 138 |
+
<selectmessage>En cliquant sur Poursuivre, vous serez redirigé(e) vers la page So Colissimo afin de choisir votre mode de livraison.</selectmessage>
|
| 139 |
+
<redirectmessage>Vous allez être redirigé(e) vers So Colissimo dans un instant...</redirectmessage>
|
| 140 |
+
<shipoutofhomeenabled>1</shipoutofhomeenabled>
|
| 141 |
+
<account></account>
|
| 142 |
+
<encryption_key></encryption_key>
|
| 143 |
+
<url_fo>http://ws.colissimo.fr/pudo-fo/storeCall.do</url_fo>
|
| 144 |
+
<active_service_is_available>1</active_service_is_available>
|
| 145 |
+
<url_service_is_available>http://ws.colissimo.fr/supervision-pudo/supervision.jsp</url_service_is_available>
|
| 146 |
+
<not_available_message>La plateforme technique So Colissimo est temporairement indisponible. Votre commande sera livrée à l'adresse de livraison que vous venez d'indiquer.</not_available_message>
|
| 147 |
+
<model>LaPoste_SoColissimoSimplicite_Model_Carrier_ShippingMethod</model>
|
| 148 |
+
<mapprefix>
|
| 149 |
+
<![CDATA[
|
| 150 |
+
{
|
| 151 |
+
"MR":"M."
|
| 152 |
+
,"MLE":"Mlle"
|
| 153 |
+
,"MME":"Mme"
|
| 154 |
+
}
|
| 155 |
+
]]>
|
| 156 |
+
</mapprefix>
|
| 157 |
+
</socolissimosimplicite>
|
| 158 |
+
</carriers>
|
| 159 |
+
</default>
|
| 160 |
+
</config>
|
app/code/community/LaPoste/SoColissimoSimplicite/etc/system.xml
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<!--
|
| 3 |
+
/**
|
| 4 |
+
* Magento
|
| 5 |
+
*
|
| 6 |
+
* NOTICE OF LICENSE
|
| 7 |
+
*
|
| 8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 10 |
+
* It is also available through the world-wide-web at this URL:
|
| 11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 12 |
+
* If you did not receive a copy of the license and are unable to
|
| 13 |
+
* obtain it through the world-wide-web, please send an email
|
| 14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 15 |
+
*
|
| 16 |
+
* @category LaPoste
|
| 17 |
+
* @package LaPoste_SoColissimoSimplicite
|
| 18 |
+
* @copyright Copyright (c) 2010 LaPoste
|
| 19 |
+
* @author Smile (http://www.smile.fr)
|
| 20 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 21 |
+
*/
|
| 22 |
+
-->
|
| 23 |
+
<config>
|
| 24 |
+
<sections>
|
| 25 |
+
<carriers>
|
| 26 |
+
<groups>
|
| 27 |
+
<socolissimosimplicite>
|
| 28 |
+
<label>So Colissimo</label>
|
| 29 |
+
<frontend_type>text</frontend_type>
|
| 30 |
+
<sort_order>100</sort_order>
|
| 31 |
+
<show_in_default>1</show_in_default>
|
| 32 |
+
<show_in_website>1</show_in_website>
|
| 33 |
+
<show_in_store>1</show_in_store>
|
| 34 |
+
<fields>
|
| 35 |
+
<active translate="label">
|
| 36 |
+
<label>Activé</label>
|
| 37 |
+
<frontend_type>select</frontend_type>
|
| 38 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 39 |
+
<sort_order>10</sort_order>
|
| 40 |
+
<show_in_default>1</show_in_default>
|
| 41 |
+
<show_in_website>1</show_in_website>
|
| 42 |
+
<show_in_store>1</show_in_store>
|
| 43 |
+
</active>
|
| 44 |
+
<title translate="label">
|
| 45 |
+
<label>Nom du transporteur</label>
|
| 46 |
+
<sort_order>20</sort_order>
|
| 47 |
+
<show_in_default>1</show_in_default>
|
| 48 |
+
<show_in_website>1</show_in_website>
|
| 49 |
+
<show_in_store>1</show_in_store>
|
| 50 |
+
</title>
|
| 51 |
+
<name translate="label">
|
| 52 |
+
<label>Nom du mode de livraison</label>
|
| 53 |
+
<sort_order>30</sort_order>
|
| 54 |
+
<show_in_default>1</show_in_default>
|
| 55 |
+
<show_in_website>1</show_in_website>
|
| 56 |
+
<show_in_store>1</show_in_store>
|
| 57 |
+
</name>
|
| 58 |
+
<selectmessage translate="label">
|
| 59 |
+
<label>Message lors de la sélection du mode de livraison</label>
|
| 60 |
+
<frontend_type>textarea</frontend_type>
|
| 61 |
+
<sort_order>31</sort_order>
|
| 62 |
+
<show_in_default>1</show_in_default>
|
| 63 |
+
<show_in_website>1</show_in_website>
|
| 64 |
+
<show_in_store>1</show_in_store>
|
| 65 |
+
</selectmessage>
|
| 66 |
+
<redirectmessage translate="label">
|
| 67 |
+
<label>Message lors de la redirection vers So Colissimo</label>
|
| 68 |
+
<frontend_type>textarea</frontend_type>
|
| 69 |
+
<sort_order>32</sort_order>
|
| 70 |
+
<show_in_default>1</show_in_default>
|
| 71 |
+
<show_in_website>1</show_in_website>
|
| 72 |
+
<show_in_store>1</show_in_store>
|
| 73 |
+
</redirectmessage>
|
| 74 |
+
<account translate="label">
|
| 75 |
+
<label>Identifiant FO</label>
|
| 76 |
+
<sort_order>40</sort_order>
|
| 77 |
+
<show_in_default>1</show_in_default>
|
| 78 |
+
<show_in_website>1</show_in_website>
|
| 79 |
+
<show_in_store>1</show_in_store>
|
| 80 |
+
</account>
|
| 81 |
+
<encryption_key translate="label">
|
| 82 |
+
<label>Clé de cryptage</label>
|
| 83 |
+
<frontend_type>text</frontend_type>
|
| 84 |
+
<sort_order>50</sort_order>
|
| 85 |
+
<show_in_default>1</show_in_default>
|
| 86 |
+
<show_in_website>1</show_in_website>
|
| 87 |
+
<show_in_store>1</show_in_store>
|
| 88 |
+
</encryption_key>
|
| 89 |
+
<url_fo translate="label">
|
| 90 |
+
<label>URL de passerelle</label>
|
| 91 |
+
<sort_order>60</sort_order>
|
| 92 |
+
<show_in_default>1</show_in_default>
|
| 93 |
+
<show_in_website>1</show_in_website>
|
| 94 |
+
<show_in_store>1</show_in_store>
|
| 95 |
+
</url_fo>
|
| 96 |
+
<active_service_is_available translate="label">
|
| 97 |
+
<label>Activer la vérification de la disponibilité</label>
|
| 98 |
+
<frontend_type>select</frontend_type>
|
| 99 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 100 |
+
<sort_order>61</sort_order>
|
| 101 |
+
<show_in_default>1</show_in_default>
|
| 102 |
+
<show_in_website>1</show_in_website>
|
| 103 |
+
<show_in_store>1</show_in_store>
|
| 104 |
+
</active_service_is_available>
|
| 105 |
+
<url_service_is_available translate="label">
|
| 106 |
+
<label>URL de vérification de la disponibilité</label>
|
| 107 |
+
<sort_order>62</sort_order>
|
| 108 |
+
<show_in_default>1</show_in_default>
|
| 109 |
+
<show_in_website>1</show_in_website>
|
| 110 |
+
<show_in_store>1</show_in_store>
|
| 111 |
+
</url_service_is_available>
|
| 112 |
+
<not_available_message translate="label">
|
| 113 |
+
<label>Message en cas d'indisponibilité de la plateforme</label>
|
| 114 |
+
<frontend_type>textarea</frontend_type>
|
| 115 |
+
<sort_order>63</sort_order>
|
| 116 |
+
<show_in_default>1</show_in_default>
|
| 117 |
+
<show_in_website>1</show_in_website>
|
| 118 |
+
<show_in_store>1</show_in_store>
|
| 119 |
+
</not_available_message>
|
| 120 |
+
<amountbasetype translate="label">
|
| 121 |
+
<label>Type des frais de livraison</label>
|
| 122 |
+
<frontend_type>select</frontend_type>
|
| 123 |
+
<source_model>socolissimosimplicite/system_config_source_shipping_amountbasetype</source_model>
|
| 124 |
+
<sort_order>70</sort_order>
|
| 125 |
+
<show_in_default>1</show_in_default>
|
| 126 |
+
<show_in_website>1</show_in_website>
|
| 127 |
+
<show_in_store>1</show_in_store>
|
| 128 |
+
</amountbasetype>
|
| 129 |
+
<amountcalculation translate="label">
|
| 130 |
+
<label>Calcul des frais de livraison</label>
|
| 131 |
+
<frontend_type>textarea</frontend_type>
|
| 132 |
+
<sort_order>80</sort_order>
|
| 133 |
+
<show_in_default>1</show_in_default>
|
| 134 |
+
<show_in_website>1</show_in_website>
|
| 135 |
+
<show_in_store>1</show_in_store>
|
| 136 |
+
<comment>
|
| 137 |
+
<![CDATA[
|
| 138 |
+
Si <strong>tarif unique</strong>, indiquer le montant (sans devise) ;<br />
|
| 139 |
+
Si <strong>tarif selon le poids</strong>,
|
| 140 |
+
indiquer :<br />
|
| 141 |
+
<code>{"</code>poids en kg<code>":"</code>tarif1<code>","</code>poids en kg<code>":"</code>tarif2<code>",</code>...<code>}</code><br />
|
| 142 |
+
Le tarif est appliqué pour un poids supérieur ou égal au poids correspondant.<br />
|
| 143 |
+
Exemple de conditions tarifaires selon le poids : <pre>{"0":"2.90","0.5":"4.50","5":"8","10":"14"}</pre>
|
| 144 |
+
]]>
|
| 145 |
+
</comment>
|
| 146 |
+
</amountcalculation>
|
| 147 |
+
<minquotepriceforfree translate="label">
|
| 148 |
+
<label>Livraison offerte à partir de (en €)</label>
|
| 149 |
+
<sort_order>90</sort_order>
|
| 150 |
+
<show_in_default>1</show_in_default>
|
| 151 |
+
<show_in_website>1</show_in_website>
|
| 152 |
+
<show_in_store>1</show_in_store>
|
| 153 |
+
<comment>Laisser vide pour ne pas offrir les frais de livraison</comment>
|
| 154 |
+
</minquotepriceforfree>
|
| 155 |
+
<shipoutofhomeenabled translate="label">
|
| 156 |
+
<label>Points de retrait hors-domicile proposés</label>
|
| 157 |
+
<frontend_type>select</frontend_type>
|
| 158 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 159 |
+
<sort_order>100</sort_order>
|
| 160 |
+
<show_in_default>0</show_in_default>
|
| 161 |
+
<show_in_website>0</show_in_website>
|
| 162 |
+
<show_in_store>0</show_in_store>
|
| 163 |
+
</shipoutofhomeenabled>
|
| 164 |
+
</fields>
|
| 165 |
+
</socolissimosimplicite>
|
| 166 |
+
</groups>
|
| 167 |
+
</carriers>
|
| 168 |
+
</sections>
|
| 169 |
+
</config>
|
app/design/frontend/default/default/layout/socolissimosimplicite.xml
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<!--
|
| 3 |
+
/**
|
| 4 |
+
* Magento
|
| 5 |
+
*
|
| 6 |
+
* NOTICE OF LICENSE
|
| 7 |
+
*
|
| 8 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
| 9 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
| 10 |
+
* It is also available through the world-wide-web at this URL:
|
| 11 |
+
* http://opensource.org/licenses/afl-3.0.php
|
| 12 |
+
* If you did not receive a copy of the license and are unable to
|
| 13 |
+
* obtain it through the world-wide-web, please send an email
|
| 14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 15 |
+
*
|
| 16 |
+
* @category design
|
| 17 |
+
* @package default_default
|
| 18 |
+
* @copyright Copyright (c) 2010 La Poste
|
| 19 |
+
* @author Smile (http://www.smile.fr)
|
| 20 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 21 |
+
*/
|
| 22 |
+
|
| 23 |
+
-->
|
| 24 |
+
<layout version="0.1.0">
|
| 25 |
+
|
| 26 |
+
<checkout_onepage_index translate="label">
|
| 27 |
+
<reference name="content">
|
| 28 |
+
<action method="unsetChild"><name>checkout.onepage</name></action>
|
| 29 |
+
|
| 30 |
+
<block type="socolissimosimplicite/onepage" name="checkout.onepage" template="checkout/onepage.phtml">
|
| 31 |
+
<block type="checkout/onepage_login" name="checkout.onepage.login" as="login" template="checkout/onepage/login.phtml">
|
| 32 |
+
<block type="page/html_wrapper" name="checkout.onepage.login.before" as="login_before">
|
| 33 |
+
<action method="setMayBeInvisible"><value>1</value></action>
|
| 34 |
+
</block>
|
| 35 |
+
</block>
|
| 36 |
+
<block type="checkout/onepage_billing" name="checkout.onepage.billing" as="billing" template="checkout/onepage/billing.phtml"/>
|
| 37 |
+
<block type="checkout/onepage_shipping" name="checkout.onepage.shipping" as="shipping" template="checkout/onepage/shipping.phtml"/>
|
| 38 |
+
<block type="checkout/onepage_shipping_method" name="checkout.onepage.shipping_method" as="shipping_method" template="socolissimosimplicite/onepage/shipping_method.phtml">
|
| 39 |
+
<block type="socolissimosimplicite/onepage_shipping_method_available" name="checkout.onepage.shipping_method.available" as="available" template="socolissimosimplicite/onepage/shipping_method/available.phtml">
|
| 40 |
+
<action method="addItemRender"><type>default</type><block>socolissimosimplicite/onepage_shipping_method_available_item</block><template>socolissimosimplicite/onepage/shipping_method/available/default.phtml</template></action>
|
| 41 |
+
<action method="addItemRender"><type>socolissimosimplicite</type><block>socolissimosimplicite/onepage_shipping_method_available_item</block><template>socolissimosimplicite/onepage/shipping_method/available/socolissimosimplicite.phtml</template></action>
|
| 42 |
+
</block>
|
| 43 |
+
<block type="checkout/onepage_shipping_method_additional" name="checkout.onepage.shipping_method.additional" as="additional" template="checkout/onepage/shipping_method/additional.phtml"/>
|
| 44 |
+
</block>
|
| 45 |
+
<block type="checkout/onepage_payment" name="checkout.onepage.payment" as="payment" template="checkout/onepage/payment.phtml">
|
| 46 |
+
<block type="checkout/onepage_payment_methods" name="checkout.payment.methods" as="methods" template="checkout/onepage/payment/methods.phtml">
|
| 47 |
+
<action method="setMethodFormTemplate"><method>purchaseorder</method><template>payment/form/purchaseorder.phtml</template></action>
|
| 48 |
+
</block>
|
| 49 |
+
</block>
|
| 50 |
+
<block type="checkout/onepage_review" name="checkout.onepage.review" as="review" template="checkout/onepage/review.phtml">
|
| 51 |
+
<block type="checkout/agreements" name="checkout.onepage.agreements" as="agreements" template="checkout/onepage/agreements.phtml"/>
|
| 52 |
+
</block>
|
| 53 |
+
</block>
|
| 54 |
+
</reference>
|
| 55 |
+
</checkout_onepage_index>
|
| 56 |
+
|
| 57 |
+
<checkout_onepage_shippingmethod>
|
| 58 |
+
<block type="socolissimosimplicite/onepage_shipping_method_available" name="root" output="toHtml" template="socolissimosimplicite/onepage/shipping_method/available.phtml">
|
| 59 |
+
<action method="addItemRender"><type>default</type><block>socolissimosimplicite/onepage_shipping_method_available_item</block><template>socolissimosimplicite/onepage/shipping_method/available/default.phtml</template></action>
|
| 60 |
+
<action method="addItemRender"><type>socolissimosimplicite</type><block>socolissimosimplicite/onepage_shipping_method_available_item</block><template>socolissimosimplicite/onepage/shipping_method/available/socolissimosimplicite.phtml</template></action>
|
| 61 |
+
</block>
|
| 62 |
+
</checkout_onepage_shippingmethod>
|
| 63 |
+
|
| 64 |
+
<socolissimosimplicite_form_send>
|
| 65 |
+
<reference name="root">
|
| 66 |
+
<action method="setTemplate"><template>page/empty.phtml</template></action>
|
| 67 |
+
</reference>
|
| 68 |
+
<reference name="content">
|
| 69 |
+
<block type="socolissimosimplicite/form" name="form.socolissimosimplicite" template="socolissimosimplicite/form.phtml" />
|
| 70 |
+
</reference>
|
| 71 |
+
</socolissimosimplicite_form_send>
|
| 72 |
+
|
| 73 |
+
<socolissimosimplicite_form_success />
|
| 74 |
+
|
| 75 |
+
<socolissimosimplicite_form_failure>
|
| 76 |
+
<reference name="content">
|
| 77 |
+
<block type="core/template" template="socolissimosimplicite/form/failure.phtml" />
|
| 78 |
+
</reference>
|
| 79 |
+
</socolissimosimplicite_form_failure>
|
| 80 |
+
|
| 81 |
+
</layout>
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
|
app/design/frontend/default/default/template/socolissimosimplicite/form.phtml
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* @category LaPoste
|
| 16 |
+
* @package LaPoste_SoColissimoSimplicite
|
| 17 |
+
* @copyright Copyright (c) 2010 La Poste
|
| 18 |
+
* @author Smile (http://www.smile.fr)
|
| 19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 20 |
+
*/
|
| 21 |
+
?>
|
| 22 |
+
<?php
|
| 23 |
+
$_address = $this->getShippingAddress();
|
| 24 |
+
$_helper = $this->helper('socolissimosimplicite');
|
| 25 |
+
?>
|
| 26 |
+
|
| 27 |
+
<?php if($this->getRedirectMessage()): ?>
|
| 28 |
+
<h3><?php echo $this->getRedirectMessage(); ?></h3>
|
| 29 |
+
<?php endif;?>
|
| 30 |
+
|
| 31 |
+
<form name="socolissimosimpliciteform" action="<?php echo $this->getUrlFoWithReturnUrlKo(); ?>" method="post">
|
| 32 |
+
|
| 33 |
+
<input type="hidden" name="pudoFOId" value="<?php echo $this->getAccountID(); ?>" />
|
| 34 |
+
|
| 35 |
+
<?php if ($_address->getPrefix()):?>
|
| 36 |
+
<input type="hidden" name="ceCivility" value="<?php echo $_helper->getPrefixForSoColissimo($_address->getPrefix()); ?>" />
|
| 37 |
+
<?php endif;?>
|
| 38 |
+
|
| 39 |
+
<?php if ($_address->getLastname()):?>
|
| 40 |
+
<input type="hidden" name="ceName" value="<?php echo $_address->getLastname(); ?>" />
|
| 41 |
+
<?php endif;?>
|
| 42 |
+
|
| 43 |
+
<?php if ($_address->getFirstname()):?>
|
| 44 |
+
<input type="hidden" name="ceFirstName" value="<?php echo $_address->getFirstname(); ?>" />
|
| 45 |
+
<?php endif;?>
|
| 46 |
+
|
| 47 |
+
<?php if ($_address->getCompany()):?>
|
| 48 |
+
<input type="hidden" name="ceCompanyName" value="<?php echo $_address->getCompany(); ?>" />
|
| 49 |
+
<?php endif;?>
|
| 50 |
+
|
| 51 |
+
<?php if ($this->getShippingAddressStreet(1)): //1ère ligne de l'adresse dans Magento = 3ème champ adresse dans SoCo ?>
|
| 52 |
+
<input type="hidden" name="ceAdress3" value="<?php echo $this->getShippingAddressStreet(1); ?>" />
|
| 53 |
+
<?php endif;?>
|
| 54 |
+
|
| 55 |
+
<?php if ($this->getShippingAddressStreet(2)):?>
|
| 56 |
+
<input type="hidden" name="ceAdress1" value="<?php echo $this->getShippingAddressStreet(2); ?>" />
|
| 57 |
+
<?php endif;?>
|
| 58 |
+
|
| 59 |
+
<?php if ($this->getShippingAddressStreet(3)):?>
|
| 60 |
+
<input type="hidden" name="ceAdress2" value="<?php echo $this->getShippingAddressStreet(3); ?>" />
|
| 61 |
+
<?php endif;?>
|
| 62 |
+
|
| 63 |
+
<?php if ($this->getShippingAddressStreet(4)):?>
|
| 64 |
+
<input type="hidden" name="ceAdress4" value="<?php echo $this->getShippingAddressStreet(4); ?>" />
|
| 65 |
+
<?php endif;?>
|
| 66 |
+
|
| 67 |
+
<?php if ($_address->getPostcode()):?>
|
| 68 |
+
<input type="hidden" name="ceZipCode" value="<?php echo $_address->getPostcode(); ?>" />
|
| 69 |
+
<?php endif;?>
|
| 70 |
+
|
| 71 |
+
<?php if ($_address->getCity()):?>
|
| 72 |
+
<input type="hidden" name="ceTown" value="<?php echo $_address->getCity(); ?>" />
|
| 73 |
+
<?php endif;?>
|
| 74 |
+
|
| 75 |
+
<?php if ($_address->getEmail()):?>
|
| 76 |
+
<input type="hidden" name="ceEmail" value="<?php echo $_address->getEmail(); ?>" />
|
| 77 |
+
<?php endif;?>
|
| 78 |
+
|
| 79 |
+
<?php if ($_address->getTelephone()):?>
|
| 80 |
+
<input type="hidden" name="cePhoneNumber" value="<?php echo $_address->getTelephone(); ?>" />
|
| 81 |
+
<?php endif;?>
|
| 82 |
+
|
| 83 |
+
<?php if ($_address->getWeight()):?>
|
| 84 |
+
<input type="hidden" name="dyWeight" value="<?php echo $_helper->getFormatedWeight($_address->getWeight()); ?>" />
|
| 85 |
+
<?php endif;?>
|
| 86 |
+
|
| 87 |
+
<input type="hidden" name="dyForwardingCharges" value="<?php echo $_helper->getFormatedShippingPrice($_address->getShippingAmount()); ?>" />
|
| 88 |
+
|
| 89 |
+
<?php if ($_address->getCustomerId()):?>
|
| 90 |
+
<input type="hidden" name="trClientNumber" value="<?php echo $_address->getCustomerId(); ?>" />
|
| 91 |
+
<?php endif;?>
|
| 92 |
+
|
| 93 |
+
<?php if ($_address->getQuoteId()):?>
|
| 94 |
+
<input type="hidden" name="trOrderNumber" value="<?php echo $_address->getQuoteId(); ?>" />
|
| 95 |
+
<?php endif;?>
|
| 96 |
+
|
| 97 |
+
<input type="hidden" name="trFirstOrder" value="<?php echo $_helper->isShipOutOfHomeDisabled(); ?>" />
|
| 98 |
+
|
| 99 |
+
<?php
|
| 100 |
+
/* donnée spécifique transmis au service, non interprétée par celui-ci et retournée
|
| 101 |
+
* en paramètre en cas de succès ou d'échec, non utilisée ici
|
| 102 |
+
* <input type="hidden" name="trParamPlus" value="" />
|
| 103 |
+
*/
|
| 104 |
+
?>
|
| 105 |
+
|
| 106 |
+
<input type="hidden" name="trReturnUrlOk" value="<?php echo $_helper->getSuccessUrl(); ?>" />
|
| 107 |
+
|
| 108 |
+
<input type="hidden" name="orderId" value="<?php echo $this->getTransaction()->getId(); ?>" />
|
| 109 |
+
|
| 110 |
+
<input type="hidden" name="signature" value="<?php echo $this->getTransaction()->getSignature(); ?>" />
|
| 111 |
+
</form>
|
| 112 |
+
|
| 113 |
+
<script type="text/javascript">
|
| 114 |
+
document.socolissimosimpliciteform.submit();
|
| 115 |
+
</script>
|
app/design/frontend/default/default/template/socolissimosimplicite/form/failure.phtml
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* @category LaPoste
|
| 16 |
+
* @package LaPoste_SoColissimoSimplicite
|
| 17 |
+
* @copyright Copyright (c) 2010 La Poste
|
| 18 |
+
* @author Smile (http://www.smile.fr)
|
| 19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 20 |
+
*/
|
| 21 |
+
?>
|
| 22 |
+
<h1><?php echo $this->__('Une erreur technique a été rencontrée') ?></h1>
|
| 23 |
+
|
| 24 |
+
<p><?php echo $this->__('Merci de soumettre votre commande ultérieurement') ?></p>
|
app/design/frontend/default/default/template/socolissimosimplicite/onepage/shipping_method.phtml
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* @category LaPoste
|
| 16 |
+
* @package LaPoste_SoColissimoSimplicite
|
| 17 |
+
* @copyright Copyright (c) 2010 La Poste
|
| 18 |
+
* @author Smile (http://www.smile.fr)
|
| 19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 20 |
+
*/
|
| 21 |
+
?>
|
| 22 |
+
<?php
|
| 23 |
+
$_helper = $this->helper('socolissimosimplicite');
|
| 24 |
+
?>
|
| 25 |
+
<form id="co-shipping-method-form" action="">
|
| 26 |
+
<div id="checkout-shipping-method-load">
|
| 27 |
+
<?php echo $this->getChildHtml('available') ?>
|
| 28 |
+
</div>
|
| 29 |
+
<script type="text/javascript">
|
| 30 |
+
//<![CDATA[
|
| 31 |
+
// update method save to redirect onSuccess to method which deals with colissimo choice
|
| 32 |
+
ShippingMethod.prototype.saveWithColissimo = function(){
|
| 33 |
+
if (checkout.loadWaiting!=false) return;
|
| 34 |
+
if (this.validate()) {
|
| 35 |
+
checkout.setLoadWaiting('shipping-method');
|
| 36 |
+
var request = new Ajax.Request(
|
| 37 |
+
this.saveUrl,
|
| 38 |
+
{
|
| 39 |
+
method:'post',
|
| 40 |
+
onComplete: this.onComplete,
|
| 41 |
+
onSuccess: this.redirectToColissimo,
|
| 42 |
+
onFailure: checkout.ajaxFailure.bind(checkout),
|
| 43 |
+
parameters: Form.serialize(this.form)
|
| 44 |
+
}
|
| 45 |
+
);
|
| 46 |
+
}
|
| 47 |
+
};
|
| 48 |
+
// check if colissimo is selected, then redirect on form which post data on this platform
|
| 49 |
+
ShippingMethod.prototype.redirectToColissimo = function(transport){
|
| 50 |
+
var rateCodeSoColissimoSimplicite = '<?php echo $_helper->getRateCode()?>';
|
| 51 |
+
var urlFormSoColissimoSimplicite = '<?php echo $_helper->getFormUrl()?>';
|
| 52 |
+
var methods = document.getElementsByName('shipping_method');
|
| 53 |
+
for (var i=0; i<methods.length; i++) {
|
| 54 |
+
if (methods[i].value == rateCodeSoColissimoSimplicite && methods[i].checked) {
|
| 55 |
+
window.location = urlFormSoColissimoSimplicite;
|
| 56 |
+
}
|
| 57 |
+
}
|
| 58 |
+
// pass to next step (= default onSave binding
|
| 59 |
+
ShippingMethod.prototype.nextStep(transport);
|
| 60 |
+
};
|
| 61 |
+
//]]>
|
| 62 |
+
</script>
|
| 63 |
+
<script type="text/javascript">
|
| 64 |
+
//<![CDATA[
|
| 65 |
+
var shippingMethod = new ShippingMethod('co-shipping-method-form', "<?php echo $this->getUrl('checkout/onepage/saveShippingMethod') ?>");
|
| 66 |
+
//]]>
|
| 67 |
+
</script>
|
| 68 |
+
<div id="onepage-checkout-shipping-method-additional-load">
|
| 69 |
+
<?php echo $this->getChildHtml('additional') ?>
|
| 70 |
+
</div>
|
| 71 |
+
<div class="buttons-set" id="shipping-method-buttons-container">
|
| 72 |
+
<p class="back-link"><a href="#" onclick="checkout.back(); return false;"><small>« </small><?php echo $this->__('Back') ?></a></p>
|
| 73 |
+
<button type="button" class="button" onclick="shippingMethod.saveWithColissimo();"><span><span><?php echo $this->__('Continue') ?></span></span></button>
|
| 74 |
+
<span id="shipping-method-please-wait" class="please-wait" style="display:none;">
|
| 75 |
+
<img src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>" alt="<?php echo $this->__('Loading next step...') ?>" title="<?php echo $this->__('Loading next step...') ?>" class="v-middle" /> <?php echo $this->__('Loading next step...') ?>
|
| 76 |
+
</span>
|
| 77 |
+
</div>
|
| 78 |
+
</form>
|
app/design/frontend/default/default/template/socolissimosimplicite/onepage/shipping_method/available.phtml
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* @category design
|
| 16 |
+
* @package default_default
|
| 17 |
+
* @copyright Copyright (c) 2010 La Poste
|
| 18 |
+
* @author Smile (http://www.smile.fr)
|
| 19 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 20 |
+
*/
|
| 21 |
+
?>
|
| 22 |
+
<?php if (!($_shippingRateGroups = $this->getShippingRates())): ?>
|
| 23 |
+
<p><?php echo $this->__('Sorry, no quotes are available for this order at this time.') ?></p>
|
| 24 |
+
<?php else: ?>
|
| 25 |
+
<dl class="sp-methods">
|
| 26 |
+
<?php $_sole = count($_shippingRateGroups) == 1; foreach ($_shippingRateGroups as $code => $_rates): ?>
|
| 27 |
+
<dt><?php echo $this->getCarrierName($code) ?></dt>
|
| 28 |
+
<dd>
|
| 29 |
+
<ul>
|
| 30 |
+
<?php $_sole = $_sole && count($_rates) == 1; foreach ($_rates as $_rate): ?>
|
| 31 |
+
<li>
|
| 32 |
+
<?php if ($_rate->getErrorMessage()): ?>
|
| 33 |
+
<ul class="messages"><li class="error-msg"><ul><li><?php echo $_rate->getErrorMessage() ?></li></ul></li></ul>
|
| 34 |
+
<?php else: ?>
|
| 35 |
+
<?php if ($_sole) : ?>
|
| 36 |
+
<span class="no-display"><input name="shipping_method" type="radio" value="<?php echo $_rate->getCode() ?>" id="s_method_<?php echo $_rate->getCode() ?>" checked="checked" /></span>
|
| 37 |
+
<?php else: ?>
|
| 38 |
+
<input name="shipping_method" type="radio" value="<?php echo $_rate->getCode() ?>" id="s_method_<?php echo $_rate->getCode() ?>"<?php if($_rate->getCode()===$this->getAddressShippingMethod()) echo ' checked="checked"' ?> class="radio" />
|
| 39 |
+
<?php endif; ?>
|
| 40 |
+
<?php echo $this->getItemHtml($_rate) ?>
|
| 41 |
+
|
| 42 |
+
<?php // disponibilité de la plateforme soco ?>
|
| 43 |
+
<?php if ($_rate->getCode() == 'socolissimosimplicite_socolissimosimplicite' and !$this->getServiceIsAvailable()): ?>
|
| 44 |
+
<ul class="messages"><li class="error-msg"><ul><li><?php echo $this->getServiceNotAvailableMessage() ?></li></ul></li></ul>
|
| 45 |
+
<?php endif ?>
|
| 46 |
+
|
| 47 |
+
<?php endif ?>
|
| 48 |
+
</li>
|
| 49 |
+
<?php endforeach; ?>
|
| 50 |
+
</ul>
|
| 51 |
+
</dd>
|
| 52 |
+
<?php endforeach; ?>
|
| 53 |
+
</dl>
|
| 54 |
+
<?php endif; ?>
|
app/design/frontend/default/default/template/socolissimosimplicite/onepage/shipping_method/available/default.phtml
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* @category design
|
| 16 |
+
* @package default_default
|
| 17 |
+
* @copyright Copyright (c) 2010 La Poste
|
| 18 |
+
* @author Smile (http://www.smile.fr)
|
| 19 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 20 |
+
*/
|
| 21 |
+
?>
|
| 22 |
+
<?php $_rate = $this->getRate() ?>
|
| 23 |
+
<label for="s_method_<?php echo $_rate->getCode() ?>"><?php echo $_rate->getMethodTitle() ?>
|
| 24 |
+
<?php $_excl = $this->getShippingPrice($_rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax()); ?>
|
| 25 |
+
<?php $_incl = $this->getShippingPrice($_rate->getPrice(), true); ?>
|
| 26 |
+
<?php echo $_excl; ?>
|
| 27 |
+
<?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
|
| 28 |
+
(<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
|
| 29 |
+
<?php endif; ?>
|
| 30 |
+
</label>
|
app/design/frontend/default/default/template/socolissimosimplicite/onepage/shipping_method/available/socolissimosimplicite.phtml
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* @category design
|
| 16 |
+
* @package default_default
|
| 17 |
+
* @copyright Copyright (c) 2010 La Poste
|
| 18 |
+
* @author Smile (http://www.smile.fr)
|
| 19 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 20 |
+
*/
|
| 21 |
+
?>
|
| 22 |
+
<?php
|
| 23 |
+
$_rate = $this->getRate();
|
| 24 |
+
$_helper = $this->helper('socolissimosimplicite');
|
| 25 |
+
$_excl = $this->getShippingPrice($_rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax());
|
| 26 |
+
?>
|
| 27 |
+
<label for="s_method_<?php echo $_rate->getCode() ?>"><?php echo $_rate->getMethodTitle() ?> <?php echo $_excl; ?></label>
|
| 28 |
+
<br />
|
| 29 |
+
<?php echo $_helper->getSelectMessage() ?>
|
app/etc/modules/LaPoste_SoColissimoSimplicite.xml
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<!--
|
| 3 |
+
/**
|
| 4 |
+
* Magento
|
| 5 |
+
*
|
| 6 |
+
* NOTICE OF LICENSE
|
| 7 |
+
*
|
| 8 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
| 9 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
| 10 |
+
* It is also available through the world-wide-web at this URL:
|
| 11 |
+
* http://opensource.org/licenses/afl-3.0.php
|
| 12 |
+
* If you did not receive a copy of the license and are unable to
|
| 13 |
+
* obtain it through the world-wide-web, please send an email
|
| 14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 15 |
+
*
|
| 16 |
+
* @category LaPoste
|
| 17 |
+
* @package LaPoste_SoColissimoSimplicite
|
| 18 |
+
* @copyright Copyright (c) 2010 LaPoste
|
| 19 |
+
* @author Smile (http://www.smile.fr)
|
| 20 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 21 |
+
*/
|
| 22 |
+
-->
|
| 23 |
+
<config>
|
| 24 |
+
<modules>
|
| 25 |
+
<LaPoste_SoColissimoSimplicite>
|
| 26 |
+
<active>true</active>
|
| 27 |
+
<codePool>community</codePool>
|
| 28 |
+
<depends>
|
| 29 |
+
<Mage_Shipping/>
|
| 30 |
+
<Mage_Checkout/>
|
| 31 |
+
</depends>
|
| 32 |
+
</LaPoste_SoColissimoSimplicite>
|
| 33 |
+
</modules>
|
| 34 |
+
</config>
|
app/locale/fr_FR/LaPoste_SoColissimoSimplicite.csv
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"Code porte","Code porte"
|
| 2 |
+
"Code porte 2","Code porte 2"
|
| 3 |
+
"Interphone","Interphone"
|
package.xml
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<package>
|
| 3 |
+
<name>ColiPoste_La_Poste_So_Colissimo</name>
|
| 4 |
+
<version>1.0.2</version>
|
| 5 |
+
<stability>stable</stability>
|
| 6 |
+
<license>GPL</license>
|
| 7 |
+
<channel>community</channel>
|
| 8 |
+
<extends/>
|
| 9 |
+
<summary>Extension officielle permettant de proposer le mode de livraison So Colissimo de La Poste / ColisPoste</summary>
|
| 10 |
+
<description><p>Cette extension officielle permet de proposer &agrave; vos clients le mode de livraison So Colissimo.</p>
|
| 11 |
+
<p>So Colissimo offre <strong>le choix parmi 5 solutions de livraison</strong> et un<strong> grand r&eacute;seau de points de retraits</strong>, partout en France m&eacute;tropolitaine pour toutes vos commandes en ligne :</p>
|
| 12 |
+
<ul>
|
| 13 |
+
<li>mon domicile : livraison &agrave; l'adresse de votre choix, entre 8h et 13h.</li>
|
| 14 |
+
<li>mon rendez-vous : livraison sur rendez-vous entre 17h et 21h30 &agrave; l'adresse de votre choix.</li>
|
| 15 |
+
<li>mon espace cityssimo : livraison dans l'un des 31 espaces Cityssimo.</li>
|
| 16 |
+
<li>mon bureau de poste : livraison dans l'un des 10.000 bureaux de poste de votre choix. </li>
|
| 17 |
+
<li>mon commer&ccedil;ant : livraison chez l'un des nombreux commer&ccedil;ants de notre r&eacute;seau partenaire.</li>
|
| 18 |
+
</ul>
|
| 19 |
+
<p>Test&eacute; et valid&eacute; sur Magento CE 1.4.1.1, PE 1.8, EE 1.8 et EE 1.9.</p>
|
| 20 |
+
<p>R&eacute;alisation par Smile.</p></description>
|
| 21 |
+
<notes>Lire le manuel d'installation</notes>
|
| 22 |
+
<authors><author><name>Berlioz</name><user>auto-converted</user><email>Aline.BERLIOZ@laposte.fr</email></author></authors>
|
| 23 |
+
<date>2010-09-17</date>
|
| 24 |
+
<time>15:49:01</time>
|
| 25 |
+
<contents><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="socolissimosimplicite.xml" hash="e192bb74c6bbfce2cbcb8981c068f028"/></dir><dir name="template"><dir name="socolissimosimplicite"><dir name="form"><file name="failure.phtml" hash="7ef359d8037ba844f513ef2f7dbab93c"/></dir><dir name="onepage"><dir name="shipping_method"><dir name="available"><file name="default.phtml" hash="2bdafa2212776b9a4caa968dbe2bcbff"/><file name="socolissimosimplicite.phtml" hash="c904763758add06b6272ef8ff885bad9"/></dir><file name="available.phtml" hash="c4554f687752ccf1572b42d910c2976e"/></dir><file name="shipping_method.phtml" hash="294cbb06b60a6013cc85dd302543aafc"/></dir><file name="form.phtml" hash="5a5a4f6195e79e08797d63f618d5ac24"/></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="fr_FR"><file name="LaPoste_SoColissimoSimplicite.csv" hash="784faaf0031ea1304bf398447749028d"/></dir></target><target name="magecommunity"><dir name="LaPoste"><dir name="SoColissimoSimplicite"><dir name="Block"><dir name="Onepage"><dir name="Shipping"><dir name="Method"><dir name="Available"><file name="Item.php" hash="db3aeb1f3631ab238060532d754d6e0f"/></dir><file name="Available.php" hash="f87e3de8eb02e26142e2827a4cd855eb"/></dir></dir></dir><file name="Form.php" hash="fa23f5274d6d871bd84665d8aac33abc"/><file name="Onepage.php" hash="92cb8a36e4d641cd92cd2fbc78859876"/></dir><dir name="controllers"><file name="FormController.php" hash="b4516f7edd52ea8e196664d5da6b69cb"/></dir><dir name="etc"><file name="config.xml" hash="764d28334ba24f38ad932b46223ceb0b"/><file name="system.xml" hash="16d1a33347d48c79c5d9e5e56b941d76"/></dir><dir name="Helper"><file name="Data.php" hash="071f9e214a69a27a259eb509fab77c3e"/></dir><dir name="Model"><dir name="Carrier"><file name="ShippingMethod.php" hash="4da636f9284ae02fc1b9d5aae1392f24"/></dir><dir name="Mysql4"><dir name="Transaction"><file name="Collection.php" hash="1460d058d25faef4cad2f9037449e0b0"/></dir><file name="Transaction.php" hash="ff3144312e5b109612429add23061085"/></dir><dir name="System"><dir name="Config"><dir name="Source"><dir name="Shipping"><file name="Amountbasetype.php" hash="c3dde687fbae69562b6dbeeecd7ea272"/></dir></dir></dir></dir><file name="Observer.php" hash="7d1f5a024d39e7491194b9fdbda9d90a"/><file name="Transaction.php" hash="b8378ab4b5850cf3b982699c212d41b4"/></dir><dir name="sql"><dir name="socolissimosimplicite_setup"><file name="mysql4-install-1.0.0.php" hash=""/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="LaPoste_SoColissimoSimplicite.xml" hash="c4fb0c85f8e71d3cd5b37f869b1e6190"/></dir></target></contents>
|
| 26 |
+
<compatible/>
|
| 27 |
+
<dependencies/>
|
| 28 |
+
</package>
|
