From 06d7ce53f23af19b76a64791aa4c238badb7dd15 Mon Sep 17 00:00:00 2001 From: TheCoreDev Date: Thu, 4 Mar 2021 17:33:34 +0100 Subject: [PATCH] =?UTF-8?q?PointRetrait=20:=20on=20d=C3=A9marre=20sur=20le?= =?UTF-8?q?=20frontOffice?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LivraisonParSecteurs/I18n/fr_FR.php | 2 +- .../LivraisonParSecteurs.php | 5 +- .../LivraisonParSecteurs/Loop/AreaLoop.php | 1 + .../default/order-delivery-extra.html | 30 +++---- local/modules/PointRetrait/Config/config.xml | 5 ++ local/modules/PointRetrait/Hook/FrontHook.php | 26 ++++++ .../modules/PointRetrait/Loop/GeneralLoop.php | 1 + local/modules/PointRetrait/PointRetrait.php | 9 +- .../backOffice/default/places-list.html | 2 +- .../default/order-delivery-extra.html | 89 +++++++++++++++++++ 10 files changed, 145 insertions(+), 25 deletions(-) create mode 100644 local/modules/PointRetrait/Hook/FrontHook.php create mode 100644 local/modules/PointRetrait/templates/frontOffice/default/order-delivery-extra.html diff --git a/local/modules/LivraisonParSecteurs/I18n/fr_FR.php b/local/modules/LivraisonParSecteurs/I18n/fr_FR.php index a89e07fc..aa3a6c02 100644 --- a/local/modules/LivraisonParSecteurs/I18n/fr_FR.php +++ b/local/modules/LivraisonParSecteurs/I18n/fr_FR.php @@ -28,7 +28,7 @@ return array( 'Format to respect' => 'Merci de respecter le format 50.255612 ou -3.121146 (le séparateur est un point et le nombre peut être négatif)', 'General' => 'Général', 'Home delivery cost' => 'Frais de livraison à domicile', - 'Message info minimum de commande' => 'Un panier d\'un montant minimum de %montant € est nécessaire pour pouvoir bénéficier de la livraison à domicile.', + 'Message info minimum de commande' => 'Livraison à domicile possible sur votre secteur : plus que %delta € pour atteindre le minimum de %minimum € et pouvoir en bénéficier.', 'Minimum amount' => 'Minimum de commande', 'Modify a delivery day' => 'Modifier un jour de livraison', 'Module name' => 'Livraison à domicile', diff --git a/local/modules/LivraisonParSecteurs/LivraisonParSecteurs.php b/local/modules/LivraisonParSecteurs/LivraisonParSecteurs.php index 4de5ef0f..d6914c33 100644 --- a/local/modules/LivraisonParSecteurs/LivraisonParSecteurs.php +++ b/local/modules/LivraisonParSecteurs/LivraisonParSecteurs.php @@ -73,11 +73,12 @@ class LivraisonParSecteurs extends AbstractDeliveryModule if ($area->getActive() === self::SECTEUR_ACTIF) { // Condition 3 : le panier doit avoir atteint le minimum de commande pour ce secteur. +/* $montantPanier = $this->getRequest()->getSession()->getSessionCart($this->getDispatcher())->getTaxedAmount($country); $montantMinimum = $area->getMinimumAmount(); - if ($montantPanier >= $montantMinimum) - $isValid = true; +*/ + $isValid = true; } } } diff --git a/local/modules/LivraisonParSecteurs/Loop/AreaLoop.php b/local/modules/LivraisonParSecteurs/Loop/AreaLoop.php index 2d2c7f9c..2fa452bb 100644 --- a/local/modules/LivraisonParSecteurs/Loop/AreaLoop.php +++ b/local/modules/LivraisonParSecteurs/Loop/AreaLoop.php @@ -51,6 +51,7 @@ class AreaLoop extends BaseLoop implements PropelSearchLoopInterface ->set("MINIMUM_AMOUNT", $lps_area->getMinimumAmount()) ->set("DELIVERY_DAYS", $deliveryDays) ->set("COVERED_CITIES_NUMBER", $citiesCount) + ->set("MODULE_ID", LivraisonParSecteurs::getModuleId()) ; $loopResult->addRow($loopResultRow); } diff --git a/local/modules/LivraisonParSecteurs/templates/frontOffice/default/order-delivery-extra.html b/local/modules/LivraisonParSecteurs/templates/frontOffice/default/order-delivery-extra.html index d07ee70d..972d2064 100644 --- a/local/modules/LivraisonParSecteurs/templates/frontOffice/default/order-delivery-extra.html +++ b/local/modules/LivraisonParSecteurs/templates/frontOffice/default/order-delivery-extra.html @@ -5,14 +5,9 @@ {loop type="lps_area" name="area-loop" id={$area_id}} {assign var=livraison value=$PRICE} {assign var=minimum value=$MINIMUM_AMOUNT} + {assign var=module_id value=$MODULE_ID} {/loop} - {if {cart attr='total_taxed_price_without_discount'} < $minimum} -
-
{intl l="Message info minimum de commande" d="livraisonparsecteurs" montant=$minimum}
-
- {/if} -
{form name="thelia.order.delivery"} @@ -34,9 +29,15 @@
+ {if {cart attr='total_taxed_price_without_discount'} < $minimum} +
+
{intl l="Message info minimum de commande" d="livraisonparsecteurs" minimum=$minimum delta=$minimum-{cart attr='total_taxed_price_without_discount'}}
+
+ {/if} +
-
+
{form name="thelia.order.delivery"}
@@ -69,20 +70,16 @@ // Masquer par défaut les options du mode LPS $(document).ready(function(){ - $("#delivery-module-38").html($('#lps_ui').html()); - $('#select-delivery-day').slideUp('fast'); + $("#delivery-module-{$module_id}").html($('#lps_ui').html()); + $('#select-lps').slideUp('fast'); }); // Gestion du pliage/dépliage du mode LPS - $('input[type=radio]').click(function() { - if ($('[delivery-mode=lps]').is(':checked')) { - $('#select-delivery-day').slideDown('fast'); - } else { - $('#select-delivery-day').slideUp('fast'); - } + $('input[type=radio][delivery-mode]').click(function() { + $('div[id^="select"]').not($('#select-' + $(this).attr('delivery-mode'))).slideUp(); + $('#select-' + $(this).attr('delivery-mode')).slideDown('fast'); }); - // $("#form-cart-delivery").off('submit').submit(function(ev) { if ($('[delivery-mode=lps]').is(':checked') && @@ -92,5 +89,4 @@ } }); - diff --git a/local/modules/PointRetrait/Config/config.xml b/local/modules/PointRetrait/Config/config.xml index 5ee46846..b0a35dd3 100644 --- a/local/modules/PointRetrait/Config/config.xml +++ b/local/modules/PointRetrait/Config/config.xml @@ -15,6 +15,11 @@ + + + + + diff --git a/local/modules/PointRetrait/Hook/FrontHook.php b/local/modules/PointRetrait/Hook/FrontHook.php new file mode 100644 index 00000000..e6c2f454 --- /dev/null +++ b/local/modules/PointRetrait/Hook/FrontHook.php @@ -0,0 +1,26 @@ +add( + $this->render( + 'order-delivery-extra.html', + [ + 'module_id' => PointRetrait::getModuleId() + ] + ) + ); + } + +} + + diff --git a/local/modules/PointRetrait/Loop/GeneralLoop.php b/local/modules/PointRetrait/Loop/GeneralLoop.php index 59672aa7..1c6e675f 100644 --- a/local/modules/PointRetrait/Loop/GeneralLoop.php +++ b/local/modules/PointRetrait/Loop/GeneralLoop.php @@ -58,6 +58,7 @@ class GeneralLoop extends BaseLoop implements PropelSearchLoopInterface ->set("ZIPCODE", $places->getZipcode()) ->set("CITY", $places->getCity()) ->set("ACCESS_COMMENT", $places->getAccessComment()) + ->set("MODULE_ID", PointRetrait::getModuleId()) ; $loopResult->addRow($loopResultRow); } diff --git a/local/modules/PointRetrait/PointRetrait.php b/local/modules/PointRetrait/PointRetrait.php index a71cd2fa..12ddf18c 100644 --- a/local/modules/PointRetrait/PointRetrait.php +++ b/local/modules/PointRetrait/PointRetrait.php @@ -6,6 +6,7 @@ use Propel\Runtime\Connection\ConnectionInterface; use Propel\Runtime\Propel; 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; @@ -65,12 +66,12 @@ class PointRetrait extends AbstractDeliveryModule $price = 0; $con = Propel::getConnection(); -// $currentAddressId = $this->getRequest()->getSession()->getOrder()->getChoosenDeliveryAddress(); -// if (!empty($currentAddressId)) { -// $zipcode = AddressQuery::create()->filterById($currentAddressId)->findOne($con)->getZipcode(); + $currentAddressId = $this->getRequest()->getSession()->getOrder()->getChoosenDeliveryAddress(); + if (!empty($currentAddressId)) { + $zipcode = AddressQuery::create()->filterById($currentAddressId)->findOne($con)->getZipcode(); // $areaId = LpsAreaCityQuery::create()->findOneByZipcode($zipcode)->getIdArea(); // $price = LpsAreaQuery::create()->findOneById($areaId)->getPrice(); -// } + } return $price; } diff --git a/local/modules/PointRetrait/templates/backOffice/default/places-list.html b/local/modules/PointRetrait/templates/backOffice/default/places-list.html index c2dfcadd..a4061315 100644 --- a/local/modules/PointRetrait/templates/backOffice/default/places-list.html +++ b/local/modules/PointRetrait/templates/backOffice/default/places-list.html @@ -1,4 +1,4 @@ -mais{extends file="admin-layout.tpl"} +{extends file="admin-layout.tpl"} {block name="no-return-functions"} {$admin_current_location = 'module'} diff --git a/local/modules/PointRetrait/templates/frontOffice/default/order-delivery-extra.html b/local/modules/PointRetrait/templates/frontOffice/default/order-delivery-extra.html new file mode 100644 index 00000000..79271394 --- /dev/null +++ b/local/modules/PointRetrait/templates/frontOffice/default/order-delivery-extra.html @@ -0,0 +1,89 @@ + + + +