PointRetrait : on démarre sur le frontOffice

This commit is contained in:
2021-03-04 17:33:34 +01:00
parent b98e6f7590
commit 06d7ce53f2
10 changed files with 145 additions and 25 deletions

View File

@@ -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',

View File

@@ -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;
}
}
}

View File

@@ -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);
}

View File

@@ -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}
<div class="row">
<div class="alert alert-danger">{intl l="Message info minimum de commande" d="livraisonparsecteurs" montant=$minimum}</div>
</div>
{/if}
<div class="row">
<div class="col-sm-4">
{form name="thelia.order.delivery"}
@@ -34,9 +29,15 @@
</div>
</div>
{if {cart attr='total_taxed_price_without_discount'} < $minimum}
<div class="row">
<div class="alert alert-info" style="margin-bottom:30px">{intl l="Message info minimum de commande" d="livraisonparsecteurs" minimum=$minimum delta=$minimum-{cart attr='total_taxed_price_without_discount'}}</div>
</div>
{/if}
<div class="row">
<div class="col-md-12">
<div id="select-delivery-day">
<div id="select-lps">
{form name="thelia.order.delivery"}
<div class="table-responsive">
<table class="table table-striped table-condensed">
@@ -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 @@
}
});
</script>

View File

@@ -15,6 +15,11 @@
<tag name="hook.event_listener" event="main.in-top-menu-items" type="back" method="onMainTopMenuTools" />
<argument type="service" id="thelia.securityContext"/>
</hook>
<hook id="pdr.front.hook" class="PointRetrait\Hook\FrontHook">
<tag name="hook.event_listener" event="order-delivery.extra" type="front" method="onOrderDeliveryExtra" />
</hook>
</hooks>
<loops>

View File

@@ -0,0 +1,26 @@
<?php
namespace PointRetrait\Hook;
use PointRetrait\PointRetrait;
use Thelia\Core\Event\Hook\HookRenderEvent;
use Thelia\Core\Hook\BaseHook;
class FrontHook extends BaseHook
{
public function onOrderDeliveryExtra(HookRenderEvent $event)
{
$event->add(
$this->render(
'order-delivery-extra.html',
[
'module_id' => PointRetrait::getModuleId()
]
)
);
}
}

View File

@@ -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);
}

View File

@@ -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;
}

View File

@@ -1,4 +1,4 @@
mais{extends file="admin-layout.tpl"}
{extends file="admin-layout.tpl"}
{block name="no-return-functions"}
{$admin_current_location = 'module'}

View File

@@ -0,0 +1,89 @@
<script type="text/html" id="pdr_ui">
{loop type="pdr_places" name="places-first-loop"}
{assign var=module_id value=$MODULE_ID}
{/loop}
<td colspan="3">
<div class="row">
<div class="col-sm-4">
{form name="thelia.order.delivery"}
{form_field field='delivery-module'}
<label for="delivery-method_{$module_id}">
<input type="radio" delivery-mode="pdr" name="{$name}" id="delivery-method_{$module_id}" value="{$module_id}">
<strong>{intl l="Module name" d="pointretrait"}</strong>
<br>
</label>
{/form_field}
{/form}
</div>
<div class="col-sm-4">&nbsp;</div>
</div>
{if {cart attr='total_taxed_price_without_discount'} < $minimum}
<!-- <div class="row">-->
<!-- <div class="alert alert-info" style="margin-bottom:30px">{intl l="Message info minimum de commande" d="livraisonparsecteurs" minimum=$minimum delta=$minimum-{cart attr='total_taxed_price_without_discount'}}</div>-->
<!-- </div>-->
{/if}
<div class="row">
<div class="col-md-5">
<div id="select-pdr">
{form name="thelia.order.delivery"}
<div class="table-responsive" style="border: 1px solid gray">
<table class="table table-striped table-condensed">
{loop type="pdr_places" name="places-loop" active=true}
<tr>
<td>
<span class="">{$TITLE}</span><br>
<span class="">{$ADDRESS1}</span><br>
<span class="">{$ZIPCODE} {$CITY}</span><br>
<table class="table">
{loop type="pdr_schedule" name="schedule-loop" place_id={$ID}}
<tr>
<td style="padding:10px; text-align: center">{$DAY_LABEL} {format_date date=$BEGIN format="H\hi"} à {format_date date=$END format="H\hi"}</td>
<td style="padding:10px; text-align: center"><input type="radio" name="lps-choosen-day" value="{$ID}"{if {cart attr='total_taxed_price_without_discount'} < $minimum} disabled{/if} /></td>
</tr>
{/loop}
</table>
</td>
</tr>
{/loop}
</table>
</div>
{/form}
</div>
</div>
<div class="col-md-7">
<div id="mondialrelay_map" style="width: 100%; height: 450px;">
</div>
</div>
</td>
</script>
<script>
// Masquer par défaut les options du mode PDR
$(document).ready(function(){
$("#delivery-module-{$module_id}").html($('#pdr_ui').html());
$('#select-pdr').slideUp('fast');
});
// Gestion du pliage/dépliage du mode PDR
$('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=pdr]').is(':checked')
&&
$('input[name=pdr-choosen-day]:checked').length === 0) {
alert("{intl l='Please select a withdrawal' d='pointretrait' js=1}");
ev.preventDefault();
}
});
</script>