Création d'un module LivraisonForfaitaire pour pouvoir choisir les frais de livraisons sur les commandes passées depuis le backOffice
This commit is contained in:
7
local/modules/LivraisonForfaitaire/Config/config.xml
Normal file
7
local/modules/LivraisonForfaitaire/Config/config.xml
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<config xmlns="http://thelia.net/schema/dic/config"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://thelia.net/schema/dic/config http://thelia.net/schema/dic/config/thelia-1.0.xsd">
|
||||
|
||||
</config>
|
||||
28
local/modules/LivraisonForfaitaire/Config/module.xml
Normal file
28
local/modules/LivraisonForfaitaire/Config/module.xml
Normal file
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module xmlns="http://thelia.net/schema/dic/module"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://thelia.net/schema/dic/module http://thelia.net/schema/dic/module/module-2_2.xsd">
|
||||
<fullnamespace>LivraisonForfaitaire\LivraisonForfaitaire</fullnamespace>
|
||||
<descriptive locale="en_US">
|
||||
<title>Permet de gérer des montants de frais de livraison forfaitaires, pour les commandes passées dans le backOffice</title>
|
||||
</descriptive>
|
||||
<descriptive locale="fr_FR">
|
||||
<title>Permet de gérer des montants de frais de livraison forfaitaires, pour les commandes passées dans le backOffice</title>
|
||||
</descriptive>
|
||||
<languages>
|
||||
<language>en_US</language>
|
||||
<language>fr_FR</language>
|
||||
</languages>
|
||||
<version>1.0.0</version>
|
||||
<authors>
|
||||
<author>
|
||||
<name>Laurent LE CORRE</name>
|
||||
<email>laurent@thecoredev.fr</email>
|
||||
</author>
|
||||
</authors>
|
||||
<type>delivery</type>
|
||||
<thelia>2.2.0</thelia>
|
||||
<stability>other</stability>
|
||||
<mandatory>0</mandatory>
|
||||
<hidden>0</hidden>
|
||||
</module>
|
||||
55
local/modules/LivraisonForfaitaire/LivraisonForfaitaire.php
Normal file
55
local/modules/LivraisonForfaitaire/LivraisonForfaitaire.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace LivraisonForfaitaire;
|
||||
|
||||
use Thelia\Model\Country;
|
||||
use Thelia\Module\AbstractDeliveryModule;
|
||||
|
||||
|
||||
class LivraisonForfaitaire extends AbstractDeliveryModule
|
||||
{
|
||||
/** @var string */
|
||||
const DOMAIN_NAME = 'livraisonforfaitaire';
|
||||
|
||||
/**
|
||||
* calculate and return delivery price
|
||||
*
|
||||
* @param Country $country
|
||||
* @throws \Exception
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getPostage(Country $country)
|
||||
{
|
||||
if (null !== $area = $this->getAreaForCountry($country)) {
|
||||
$select = $this->getRequest()->get('select-forfait');
|
||||
if ($select !== null && $select !== "")
|
||||
$postage = $select;
|
||||
else
|
||||
$postage = $area->getPostage();
|
||||
|
||||
} else {
|
||||
throw new \InvalidArgumentException("Country or Area should not be null");
|
||||
}
|
||||
|
||||
return $postage === null ? 0 : $postage;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called by the Delivery loop, to check if the current module has to be displayed to the customer.
|
||||
* Override it to implements your delivery rules/
|
||||
*
|
||||
* If you return true, the delivery method will de displayed to the customer
|
||||
* If you return false, the delivery method will not be displayed
|
||||
*
|
||||
* @param Country $country the country to deliver to.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isValidDelivery(Country $country)
|
||||
{
|
||||
// We should find an area for the country.
|
||||
return null !== $this->getAreaForCountry($country);
|
||||
}
|
||||
|
||||
}
|
||||
55
local/modules/LivraisonForfaitaire/Readme.md
Normal file
55
local/modules/LivraisonForfaitaire/Readme.md
Normal file
@@ -0,0 +1,55 @@
|
||||
# Livraison Forfaitaire
|
||||
|
||||
Add a short description here. You can also add a screenshot if needed.
|
||||
|
||||
## Installation
|
||||
|
||||
### Manually
|
||||
|
||||
* Copy the module into ```<thelia_root>/local/modules/``` directory and be sure that the name of the module is LivraisonForfaitaire.
|
||||
* Activate it in your thelia administration panel
|
||||
|
||||
### Composer
|
||||
|
||||
Add it in your main thelia composer.json file
|
||||
|
||||
```
|
||||
composer require your-vendor/livraison-forfaitaire-module:~1.0
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Explain here how to use your module, how to configure it, etc.
|
||||
|
||||
## Hook
|
||||
|
||||
If your module use one or more hook, fill this part. Explain which hooks are used.
|
||||
|
||||
|
||||
## Loop
|
||||
|
||||
If your module declare one or more loop, describe them here like this :
|
||||
|
||||
[loop name]
|
||||
|
||||
### Input arguments
|
||||
|
||||
|Argument |Description |
|
||||
|--- |--- |
|
||||
|**arg1** | describe arg1 with an exemple. |
|
||||
|**arg2** | describe arg2 with an exemple. |
|
||||
|
||||
### Output arguments
|
||||
|
||||
|Variable |Description |
|
||||
|--- |--- |
|
||||
|$VAR1 | describe $VAR1 variable |
|
||||
|$VAR2 | describe $VAR2 variable |
|
||||
|
||||
### Exemple
|
||||
|
||||
Add a complete exemple of your loop
|
||||
|
||||
## Other ?
|
||||
|
||||
If you have other think to put, feel free to complete your readme as you want.
|
||||
11
local/modules/LivraisonForfaitaire/composer.json
Normal file
11
local/modules/LivraisonForfaitaire/composer.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "your-vendor/livraison-forfaitaire-module",
|
||||
"license": "LGPL-3.0+",
|
||||
"type": "thelia-module",
|
||||
"require": {
|
||||
"thelia/installer": "~1.1"
|
||||
},
|
||||
"extra": {
|
||||
"installer-name": "LivraisonForfaitaire"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
return array(
|
||||
// 'an english string' => 'The displayed english string',
|
||||
);
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
'Error' => 'Erreur',
|
||||
'Secret key' => 'Clé secrète',
|
||||
'Site key' => 'Clé du site',
|
||||
'Sorry, it seems that you\'re not human.' => 'Désolé, il semblerait que vous ne soyez pas un être humain.'
|
||||
);
|
||||
Reference in New Issue
Block a user