Il manquait des fichiers dans le commit du module LivraisonParSecteurs
This commit is contained in:
32
local/modules/LivraisonParSecteurs/Config/config.xml
Normal file
32
local/modules/LivraisonParSecteurs/Config/config.xml
Normal file
@@ -0,0 +1,32 @@
|
||||
<?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">
|
||||
|
||||
<forms>
|
||||
<form name="livraisonparsecteurs_config_general" class="LivraisonParSecteurs\Form\ConfigForm" />
|
||||
<form name="livraisonparsecteurs_config_schedule" class="LivraisonParSecteurs\Form\ConfigForm" />
|
||||
<form name="livraisonparsecteurs_config_cities" class="LivraisonParSecteurs\Form\ConfigForm" />
|
||||
</forms>
|
||||
|
||||
<loops>
|
||||
<loop name="lps_area" class="LivraisonParSecteurs\Loop\AreaLoop"/>
|
||||
<loop name="lps_area_schedule" class="LivraisonParSecteurs\Loop\AreaScheduleLoop"/>
|
||||
<loop name="lps_area_cities" class="LivraisonParSecteurs\Loop\AreaCitiesLoop"/>
|
||||
</loops>
|
||||
|
||||
<!--
|
||||
<services>
|
||||
|
||||
</services>
|
||||
-->
|
||||
|
||||
<hooks>
|
||||
<hook id="livraisonparsecteurs.admin.hook" class="LivraisonParSecteurs\Hook\AdminHook">
|
||||
<tag name="hook.event_listener" event="module.configuration" type="back" method="onModuleConfig" />
|
||||
<argument type="service" id="thelia.securityContext"/>
|
||||
</hook>
|
||||
</hooks>
|
||||
|
||||
</config>
|
||||
28
local/modules/LivraisonParSecteurs/Config/module.xml
Normal file
28
local/modules/LivraisonParSecteurs/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>LivraisonParSecteurs\LivraisonParSecteurs</fullnamespace>
|
||||
<descriptive locale="en_US">
|
||||
<title>Define a delivery area, depending on customer's zip code</title>
|
||||
</descriptive>
|
||||
<descriptive locale="fr_FR">
|
||||
<title>Permet de gérer les secteurs de livraison des clients, en fonction de leur code postal</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.3.x</thelia>
|
||||
<stability>alpha</stability>
|
||||
<mandatory>0</mandatory>
|
||||
<hidden>0</hidden>
|
||||
</module>
|
||||
44
local/modules/LivraisonParSecteurs/Config/schema.xml
Normal file
44
local/modules/LivraisonParSecteurs/Config/schema.xml
Normal file
@@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<database defaultIdMethod="native" name="thelia"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="../../../core/vendor/thelia/propel/resources/xsd/database.xsd" >
|
||||
|
||||
<table name="lps_area" namespace="LivraisonParSecteurs\Model">
|
||||
<column name="id" primaryKey="true" required="true" type="INTEGER" />
|
||||
<column name="title" required="true" size="50" type="VARCHAR" />
|
||||
<column name="active" required="true" type="TINYINT" defaultValue="1" />
|
||||
<column name="price" required="true" type="INTEGER" defaultValue="0" />
|
||||
|
||||
<behavior name="timestampable" />
|
||||
</table>
|
||||
|
||||
|
||||
<table name="lps_area_city" namespace="LivraisonParSecteurs\Model">
|
||||
<column autoIncrement="true" name="id" primaryKey="true" required="true" type="INTEGER" />
|
||||
<column name="id_area" required="true" type="INTEGER" />
|
||||
<column name="zipcode" required="true" size="10" type="VARCHAR" />
|
||||
|
||||
<foreign-key foreignTable="lps_area" name="fk_area_area_city" onDelete="CASCADE">
|
||||
<reference foreign="id" local="id_area"/>
|
||||
</foreign-key>
|
||||
|
||||
<behavior name="timestampable" />
|
||||
</table>
|
||||
|
||||
|
||||
<table name="lps_area_schedule" namespace="LivraisonParSecteurs\Model">
|
||||
<column autoIncrement="true" name="id" primaryKey="true" required="true" type="INTEGER" />
|
||||
<column name="id_area" required="true" type="INTEGER" />
|
||||
<column name="day" required="true" type="INTEGER" />
|
||||
|
||||
<column name="begin_time" required="true" type="TIME" />
|
||||
<column name="end_time" required="true" type="TIME" />
|
||||
|
||||
<foreign-key foreignTable="lps_area" name="fk_area_area_schedule" onDelete="CASCADE">
|
||||
<reference foreign="id" local="id_area"/>
|
||||
</foreign-key>
|
||||
|
||||
<behavior name="timestampable" />
|
||||
</table>
|
||||
|
||||
</database>
|
||||
5
local/modules/LivraisonParSecteurs/I18n/en_US.php
Normal file
5
local/modules/LivraisonParSecteurs/I18n/en_US.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
return array(
|
||||
// 'an english string' => 'The displayed english string',
|
||||
'My areas' => 'My delivery areas',
|
||||
);
|
||||
16
local/modules/LivraisonParSecteurs/I18n/fr_FR.php
Normal file
16
local/modules/LivraisonParSecteurs/I18n/fr_FR.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
return array(
|
||||
'Active' => 'Actif',
|
||||
'Actions' => 'Actions',
|
||||
'Area name' => 'Nom du secteur',
|
||||
'Cities' => 'Communes couvertes',
|
||||
'Delivery days' => 'Jours de livraison',
|
||||
'Delivery price' => 'Prix de la livraison',
|
||||
'Edit an area' => 'Modifier le secteur',
|
||||
'General' => 'Général',
|
||||
'Home delivery cost' => 'Frais de livraison à domicile',
|
||||
'My areas' => 'Mes secteurs de livraison',
|
||||
'Save' => 'Sauvegarder',
|
||||
'Schedule' => 'Horaires',
|
||||
'Title of config view' => 'Module LivraisonParSecteurs - Configuration'
|
||||
);
|
||||
81
local/modules/LivraisonParSecteurs/LivraisonParSecteurs.php
Normal file
81
local/modules/LivraisonParSecteurs/LivraisonParSecteurs.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace LivraisonParSecteurs;
|
||||
|
||||
use LivraisonParSecteurs\Model\LpsSecteurQuery;
|
||||
use Propel\Runtime\Connection\ConnectionInterface;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Install\Database;
|
||||
use Thelia\Model\AddressQuery;
|
||||
use Thelia\Model\Country;
|
||||
use Thelia\Model\OrderPostage;
|
||||
use Thelia\Module\AbstractDeliveryModule;
|
||||
use Thelia\Module\Exception\DeliveryException;
|
||||
|
||||
class LivraisonParSecteurs extends AbstractDeliveryModule
|
||||
{
|
||||
/** @var string */
|
||||
const DOMAIN_NAME = 'livraisonparsecteurs';
|
||||
const MESSAGE_DOMAIN = "livraisonparsecteurs";
|
||||
|
||||
|
||||
/**
|
||||
* @param ConnectionInterface|null $con
|
||||
*/
|
||||
public function postActivation(ConnectionInterface $con = null)
|
||||
{
|
||||
$database = new Database($con->getWrappedConnection());
|
||||
$database->insertSql(null, array(__DIR__ . '/Config/thelia.sql'));
|
||||
$database->insertSql(null, array(__DIR__ . '/Config/insert.sql'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
// Get current addressId
|
||||
$currentAddressId = $this->getRequest()->request->get('address_id');
|
||||
|
||||
if (empty($currentAddressId)) {
|
||||
if (null !== $customer = $this->getRequest()->getSession()->getCustomerUser()) {
|
||||
$currentAddressId = AddressQuery::create()
|
||||
->filterByCustomer($customer)
|
||||
->filterByIsDefault(1)
|
||||
->select('ID')
|
||||
->findOne();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Calculate and return delivery price in the shop's default currency
|
||||
*
|
||||
* @param Country $country the country to deliver to.
|
||||
*
|
||||
* @return OrderPostage|float the delivery price
|
||||
* @throws DeliveryException if the postage price cannot be calculated.
|
||||
*/
|
||||
public function getPostage(Country $country)
|
||||
{
|
||||
if (! $this->isValidDelivery($country)) {
|
||||
throw new DeliveryException(
|
||||
Translator::getInstance()->trans("This module cannot be used on the current cart.")
|
||||
);
|
||||
}
|
||||
|
||||
return LpsSecteurQuery::create()->findOneByActive(1)->getPrice();
|
||||
}
|
||||
|
||||
}
|
||||
55
local/modules/LivraisonParSecteurs/Readme.md
Normal file
55
local/modules/LivraisonParSecteurs/Readme.md
Normal file
@@ -0,0 +1,55 @@
|
||||
# Secteurs Livraison
|
||||
|
||||
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 LivraisonParSecteurs\.
|
||||
* Activate it in your thelia administration panel
|
||||
|
||||
### Composer
|
||||
|
||||
Add it in your main thelia composer.json file
|
||||
|
||||
```
|
||||
composer require your-vendor/secteurs-livraison-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.
|
||||
12
local/modules/LivraisonParSecteurs/composer.json
Normal file
12
local/modules/LivraisonParSecteurs/composer.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"name": "thecoredev/secteurs-livraison-module",
|
||||
"description": "LivraisonParSecteurs\ module for Thelia",
|
||||
"license": "LGPL-3.0-or-later",
|
||||
"type": "thelia-module",
|
||||
"require": {
|
||||
"thelia/installer": "~1.1"
|
||||
},
|
||||
"extra": {
|
||||
"installer-name": "LivraisonParSecteurs\"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user