{% extends 'admin/base.html.twig' %}
{% block title %}La livraison et coupon rabais
{% endblock %}
{% block _cart_checkout_newAddress_widget %}
<div class="row">
<div class="col-md-8">{{form_row(form.name)}}</div>
<div class="col-md-4">{{form_row(form.phone)}}</div>
</div>
<div class="row">
<div class="col-md-3">{{form_row(form.civicNumber)}}</div>
<div class="col-md-6">{{form_row(form.streetName)}}</div>
<div class="col-md-3">{{form_row(form.unit)}}</div>
</div>
<div class="row">
<div class="col-md-4">{{form_row(form.city)}}</div>
<div class="col-md-4">{{form_row(form.province)}}</div>
<div class="col-md-4">{{form_row(form.zipCode)}}</div>
</div>
{#
<div class="row">
<div class="col-md-12">{{form_row(form.note)}}</div>
</div>
#}
{% endblock %}
{% block CSS %}
<link rel="stylesheet" href="//code.jquery.com/ui/1.13.0/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/resources/demos/style.css">
<link rel="stylesheet" type="text/css" href="{{ asset('build/frontend/checkout.css') }}">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/css/bootstrap-datepicker.min.css" integrity="sha512-mSYUmp1HYZDFaVKK//63EcZq4iFWFjxSL+Z3T/aCt4IO9Cejm03q3NKKYN6pFQzY0SBOr8h+eCIAZHPXcpZaNw==" crossorigin="anonymous" />
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-beta.1/dist/css/select2.min.css" rel="stylesheet"/>
{% endblock %}
{% block JS %}
<script src="{{ asset('build/frontend/checkout.js') }}"></script>
<script src="/assets/frontend/js/jquery-3.1.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js" integrity="sha512-qTXRIMyZIFb8iQcfjXWCO8+M5Tbc38Qi5WzdPOYZHIlZpzBHG3L3by84BBBOiRGiEb7KKtAOAs5qYdUiZiQNNQ==" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/locale/fr.min.js" integrity="sha512-RAt2+PIRwJiyjWpzvvhKAG2LEdPpQhTgWfbEkFDCo8wC4rFYh5GQzJBVIFDswwaEDEYX16GEE/4fpeDNr7OIZw==" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-beta.1/dist/js/select2.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/js/bootstrap-datepicker.min.js" integrity="sha512-T/tUfKSV1bihCnd+MxKD0Hm1uBBroVYBOYSk1knyvQ9VyZJpc/ALb4P0r6ubwVPSGB2GvjeoMAJJImBG12TiaQ==" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/locales/bootstrap-datepicker.fr.min.js" integrity="sha512-fx3aztaUjb4NyoD+Tso5g7R1l29bU3jnnTfNRKBiY9fdQOHzVhKJ10wEAgQ1zM/WXCzB9bnVryHD1M40775Tsw==" crossorigin="anonymous"></script>
{% if global.getCart.hasJIT %}
<script>
var cartHasJIT = true;
</script>
{% else %}
<script>
var cartHasJIT = false;
</script>
{% endif %}
<script type="text/javascript">
//$("#action_shipping").prop("checked", true);
$('#checkPickUp').css("color", "gray");
var actionShipping = document.querySelector('#action_shipping');
{# console.log(actionShipping.checked); #}
if (actionShipping.checked == false){
$("#choiceShippingDate").hide();
$("#blocPickUp").show();
$("#blocShipping").hide();
$('#checkPickUp').css("color", "black");
$('#checkShipping').css("color", "gray");
}else if(actionShipping.checked == true){
$("#blocPickUp").hide();
$("#blocShipping").show();
$("#choiceShippingDate").show();
$('#checkShipping').css("color", "black");
//$('#checkGift').css("color", "gray");
$('#checkPickUp').css("color", "gray");
$("#blocGift").show();
}
//$('#checkGift').css("color", "gray");
$(document.body).on("click",'.choiceCustomShipping', function() {
var test = $(".choiceCustomShipping").not(this).prop('checked', false);
//console.log(test.val());
if (this.checked) {
this.setAttribute("checked", "checked");
var selectBox = $(this).val();
//console.log(selectBox);
if (selectBox == "domicile"){
$("#blocPickUp").hide();
$("#blocShipping").show();
$("#choiceShippingDate").show();
$('#checkShipping').css("color", "black");
//$('#checkGift').css("color", "gray");
$('#checkPickUp').css("color", "gray");
$("#blocGift").show();
}else if(selectBox == "cueillette") {
$("#DeliveryChoiceCheckbox").removeAttr('checked');
$("#pickupSchedule").attr("disabled", false);
$("#choiceShippingDate").hide();
$("#pickupAdressBlock").show();
$("#blocPickUp").show();
$("#blocShipping").hide();
$('#checkPickUp').css("color", "black");
$('#checkShipping').css("color", "gray");
$('#checkGift').removeAttr('checked');
$("#blocGift").hide();
}
/*else{
$("#blocShipping").hide();
$("#choiceShippingDate").show();
// $('#checkGift').css("color", "black");
$('#checkShipping').css("color", "gray");
$('#checkPickUp').css("color", "gray");
// $("#blocGift").show();
$("#blocPickUp").hide();
}*/
}
test.removeAttr('checked');
});
$(function () {
$(document.body).on('change','#adresse_province', function(e) {
if ($(this).val() == "QC") {
$('#newAddress_cityQC').show();
$('#newAddress_cityAny').hide();
$('#newAddress_cityON').hide();
}else if ($(this).val() == "ON") {
$('#newAddress_cityQC').hide();
$('#newAddress_cityAny').hide();
$('#newAddress_cityON').show();
} else {
$('#newAddress_cityQC').hide();
$('#newAddress_cityAny').show();
$('#newAddress_cityON').hide();
}
});
$(document.body).on('click','#proceedToPaymentSubmitBtn', function(e) {
var formIsValid = true;
var errorMsg = 'Veuillez remplir ce champ.';
if ($('#checkoutAddressSelection').val() == "none") {
var selectCheckbox = document.getElementById("pickupScheduleCheckbox");
var selectCheckboxValue = selectCheckbox.checked;
//console.log(selectCheckboxValue);
if (selectCheckboxValue == false){
//SaveMyAdresse();
var selector = 'newAddress_name';
if (!$('#'+selector).val()) {
$('#'+selector).get(0).setCustomValidity(errorMsg);
formIsValid = false;
} else {
$('#'+selector).get(0).setCustomValidity("");
}
{# var selector = 'street_number';
if (!$('#'+selector).val()) {
$('#'+selector).get(0).setCustomValidity(errorMsg);
formIsValid = false;
} else {
$('#'+selector).get(0).setCustomValidity("");
} #}
var selector = 'postal_code';
if (!$('#'+selector).val()) {
$('#'+selector).get(0).setCustomValidity(errorMsg);
formIsValid = false;
} else {
$('#'+selector).get(0).setCustomValidity("");
}
var selector = 'newAddress_phone';
if (!$('#'+selector).val()) {
$('#'+selector).get(0).setCustomValidity(errorMsg);
formIsValid = false;
} else {
$('#'+selector).get(0).setCustomValidity("");
}
}
}
//console.log(selector);
if (!formIsValid) {
document.getElementById('se-pre-con').style.display='none';
} else {
$('#proceedToPaymentForm').submit();
document.getElementById('se-pre-con').style.display='initial';
}
});
$(document.body).on('change','#checkoutAddressSelection', function(e) {
if ($(this).val() == "none") {
$('#add_new_address').show();
$('#proceedToPaymentSubmitBtn').html("Enregistrer et Passer au Paiement");
} else {
$('#proceedToPaymentSubmitBtn').html("Passer au paiement");
$('#add_new_address').hide();
}
updateDeliveryDateEstimate();
});
$(document.body).on('change','#newAddress_citySelectQC', function(e) {
updateDeliveryDateEstimate();
});
$(document.body).on('change','#newAddress_citySelectON', function(e) {
updateDeliveryDateEstimate();
});
$(document.body).on('change','#newAddress_cityInputAny', function(e) {
updateDeliveryDateEstimate();
});
var updateDeliveryDateEstimate = function() {
//$('#deliveryEstimateCard').hide();
//$('#deliveryEstimateSpinner').show();
var shippingAddressId = $('#checkoutAddressSelection').val();
var shippingAddressCity = false;
var newAddressProvince = $('#newAddress_province').find(":selected").val();
if (shippingAddressId == "none") {
if (newAddressProvince == "QC") {
shippingAddressCity = $('#newAddress_citySelectQC').val();
} else if (newAddressProvince == "ON") {
shippingAddressCity = $('#newAddress_citySelectON').val();
} else {
shippingAddressCity = $('#newAddress_cityInputAny').val();
}
}
if (shippingAddressId == "none" && !shippingAddressCity) {
return;
}
$.post( "/deliveryEstimateAjax", {
shippingAddressId: shippingAddressId,
shippingAddressCity: shippingAddressCity,
newAddressProvince: newAddressProvince
}).done(function( jsonData ) {
var data = JSON.parse(jsonData);
//console.log( data );
var options = { weekday: 'long',year: 'numeric', month: 'long', day: 'numeric' };
var daylivraison = new Date(data.route);
var livraison = daylivraison.toLocaleDateString("fr-FR", options);
var thisDay = new Date();
var phraseDateChoice = null
var spanEvolutiveDateDelivery = null;
var phraseDateChoice = null;
if (data.dow != false){
spanEvolutiveDateDelivery = document.getElementById('evolutiveDateDelivery');
phraseDateChoice = livraison;
}else {
Date.prototype.addDays = function(days) {
var date = new Date(this.valueOf());
date.setDate(date.getDate() + days);
return date;
}
if (thisDay.getDay() == 1 || thisDay.getDay() == 2){
if (thisDay.getDay() == 2 && thisDay.getHours() < 12){
var Purolivraison = new Date(daylivraison.getTime() + 7 * 24 * 60 * 60 * 1000);
}
var Purolivraison = daylivraison;
}else{
var Purolivraison = daylivraison;
}
var PuroFormatLivraison = Purolivraison.toLocaleDateString("fr-FR", options);
var addTwoDaysToDate = Purolivraison.addDays(2);
var livraisonAdd48h = addTwoDaysToDate.toLocaleDateString("fr-FR", options);
spanEvolutiveDateDelivery = document.getElementById('evolutiveDateDelivery');
phraseDateChoice = ' entre le ' + PuroFormatLivraison + ' et le ' + livraisonAdd48h;
}
//console.log(phraseDateChoice);
if (phraseDateChoice){
spanEvolutiveDateDelivery.innerHTML = phraseDateChoice;
}
var daysOfWeekDisabled = [0,1,2,3,4,5,6];
if (data.dow) {
var index = daysOfWeekDisabled.indexOf(data.dow);
if (index !== -1) {
daysOfWeekDisabled.splice(index, 1);
}
} else {
daysOfWeekDisabled = [0,1,5,6];
}
if (data.idRoute == "19") {
daysOfWeekDisabled = [0,1,5,6];
}
if (data.idRoute == "18" || data.nameRoute == "Agglo Longueuil") {
daysOfWeekDisabled = [0,1,5,6];
}
$( "#datepickerCustomDelivery" ).datepicker('destroy');
var now = new Date();
var startDate = new Date();
if (cartHasJIT){
if (now.getDay() == 6 || now.getDay() == 0){
var numberOfDaysToAdd = 2;
}else if (now.getDay() >= 1 || now.getDay() <= 3){
var numberOfDaysToAdd = 5;
}else{
var numberOfDaysToAdd = 2;
}
}else{
if (data.dow != false){
var numberOfDaysToAdd = 2;
}else{
var numberOfDaysToAdd = 5;
}
}
startDate.setDate(startDate.getDate() + numberOfDaysToAdd);
$( "#datepickerCustomDelivery" ).datepicker({
daysOfWeekDisabled: daysOfWeekDisabled,
endDate: '+2m',
orientation: "bottom left",
startDate: startDate,
format: 'DD d MM yyyy',
language: 'fr'
});
$('#deliveryEstimateSpinner').hide();
$('#deliveryEstimateCard').show();
});
}
$(function() {
$('#pickupScheduleCheckbox').click(function() {
$('#DeliveryChoiceCheckbox').prop( "checked", false );
});
$('#DeliveryChoiceCheckbox').change(function () {
if ($(this).prop('checked')) {
$('#pickupAdressBlock').hide();
$('#pickupSchedule').attr("disabled", true);
$('#action_gift').attr("disabled", false);
$('#pickupScheduleCheckbox').prop( "checked", false );
$('#customDelivery').show();
} else {
$('#customDelivery').hide();
}
});
$("#datepickerCustomDelivery").on("change",function() {
var selected = $(this).val();
//console.log(selected);
$("#datepickerCustomDelivery").datepicker('hide');
spanEvolutiveDateDelivery = document.getElementById('evolutiveDateDelivery');
if (selected){
spanEvolutiveDateDelivery.innerHTML = selected;
}
});
});
updateDeliveryDateEstimate();
var now = new Date();
now.setDate(now.getDate() + 1);
var startDate = now;
if (cartHasJIT) {
console.log('+++with jit');
var x = 2;
var now = new Date();
now.setDate(now.getDate() + (x+(7-now.getDay())) % 7);
startDate = now;
}
/*console.log("----");
console.log(moment(startDate).format("DD d MM yyyy"));
console.log("----");*/
$('#pickupSchedule').datepicker({
format: 'dd/mm/yyyy',
startDate: moment(startDate).format("DD d MM yyyy"),
autoclose: true,
language: 'fr',
// minDate: moment().add(12, "hours").format("DD/MM/YYYY"),
endDate: moment().add(7, "days").format("DD d MM yyyy"),
}).on('changeDate', function(e) {
var date = e.date;
var selected_date = moment(date).format("DD/MM/YYYY");
var tomorrow_date = moment().add(1, "day").format("DD d MM yyyy");
var is_tomorrow = false;
if (selected_date == tomorrow_date) {
is_tomorrow = true;
}
var dayOfWeek = date.getDay();
generateDateTimePicker(dayOfWeek, is_tomorrow);
});
$(document.body).on('change','#cart_checkout_newAddress_province', function(e) {
if ($(this).val()=="QC") {
$('.citySearchClass').next(".select2-container").show();
$('.citySearchClass').replaceWith('<select id="cart_checkout_newAddress_city" class="form-control citySearchClass" name="cart_checkout[newAddress][city]" style="display:none;"></select>');
} else {
$('.citySearchClass').next(".select2-container").hide();
$('.citySearchClass').replaceWith('<input type="text" name="cart_checkout[newAddress][city]" required class="form-control citySearchClass">');
}
// $('#manualCityName').show();
});
$(document.body).on('click','#timepicker_hour', function(e) {
$( ".timepicker-selected" ).each(function( index, element ) {
$(element).removeClass("timepicker-selected");
});
$(this).find("div").addClass("timepicker-selected");
var hour = $(this).attr("data-id");
var pickupSchedule = $('#pickupSchedule').val() + ' ' + hour;
$('#pickupScheduleHidden').val(pickupSchedule);
});
var generateDateTimePicker = function(dayOfWeek, is_tomorrow) {
$('#pickupScheduleHidden').val('');
var HTML = '';
var schedule = JSON.parse(pickupSchedule);
if (!schedule[String(dayOfWeek)]) {
HTML += '<div class="col-12" > \
<div class="timepicker-hour-box timepicker-warning"> \
<strong>Aucune disponibilitée durant cette journée. Veuillez choisir une autre date.</strong> \
</div> \
</div>';
}
var hours = schedule[String(dayOfWeek)];
for(hour in hours) {
var is_disabled = false;
if (is_tomorrow) {
if (moment().format("HH\hmm") >="12h00" && hours[hour][0] <= "12h00") {
is_disabled = true;
}
}
if (cartHasJIT) {
//between tuesday 12 PM to friday 12PM for JIT
if (dayOfWeek == 2) {
if (hours[hour][0] < "12h00") {
is_disabled = true;
}
}
/*if (dayOfWeek == 5) {
if (hours[hour][0] > "12h00") {
is_disabled = true;
}
}*/
}
HTML += '<div class="col-3 mb-3" ';
if (!is_disabled) {
HTML += ' id="timepicker_hour" ';
}
HTML += ' data-id="'+hours[hour][0]+'"> \
<div class="timepicker-hour-box';
if (is_disabled) {
HTML += ' timepicker-hour-box-disabled ';
}
HTML += '"> \
<strong>'+hours[hour][0]+'</strong> \
</div> \
</div>';
}
$('#dateTimePickerRow').html(HTML);
$('#datetime_picker').show();
$('#dateTimePickerRow').show();
}
var pickupLocationScheduleDisplay = function() {
var HTML = '';
var schedule = JSON.parse(pickupSchedule);
for ( dayOfWeek in schedule) {
var dayOfWeekString = '';
if (dayOfWeek == 1) { dayOfWeekString = "Lundi"; }
if (dayOfWeek == 2) { dayOfWeekString = "Mardi"; }
if (dayOfWeek == 3) { dayOfWeekString = "Mercredi"; }
if (dayOfWeek == 4) { dayOfWeekString = "Jeudi"; }
if (dayOfWeek == 5) { dayOfWeekString = "Vendredi"; }
if (dayOfWeek == 6) { dayOfWeekString = "Samedi"; }
if (dayOfWeek == 7) { dayOfWeekString = "Dimanche"; }
HTML += "• " + dayOfWeekString + " : ";
var hours = schedule[String(dayOfWeek)];
var hours_start = hours.shift();
var hours_end = hours[hours.length - 1];
HTML += hours_start[0] + ' à ' + hours_end[1];
HTML += "<br/>" ;
}
$('#pickupLocationScheduleDisplay').html(HTML);
}
pickupLocationScheduleDisplay();
$('#pickupLocations').change(function () {
$('#datetimeSelectionRow').show();
var newPickupLocation = $('#pickupLocations').val();
$('#pickupLocation').val(newPickupLocation);
var pickupSchedulesObject = JSON.parse(pickupSchedules);
var newPickupSchedule = JSON.stringify(pickupSchedulesObject[newPickupLocation]);
pickupSchedule = newPickupSchedule;
var _daysOfWeekDisabled = [ 0, 1, 2, 3, 4, 5, 6 ];
for ( var index in pickupSchedulesObject[newPickupLocation] ) {
if (cartHasJIT && index == 1) {
continue;
}
delete _daysOfWeekDisabled[index];
}
var _daysOfWeekDisabled = _daysOfWeekDisabled.filter(function (el) {
return el != null;
});
$('#pickupSchedule').datepicker('destroy');
var now = new Date('monday');
var _startDate ;
if (now.getDay() >= 3 && cartHasJIT) {
//if wednesday go to next week
var startDate = 7-now.getDay() ;
_startDate = moment().add(startDate, "days").format("DD/MM/YYYY");
_endDate = moment(_startDate, 'DD/MM/YYYY').add(10, "days").format("DD/MM/YYYY");
}else{
_startDate = moment().add(1, "days").format("DD/MM/YYYY");
_endDate = moment(_startDate, 'DD/MM/YYYY').add(10, "days").format("DD/MM/YYYY");
}
if (cartHasJIT) {
console.log("cart has JIT");
const dayINeed = 2; // for tuesday
const today = moment().isoWeekday();
// if we haven't yet passed the day of the week that I need:
/*if (today <= dayINeed) {
_startDate= moment().isoWeekday(dayINeed).format("DD/MM/YYYY");
} else {*/
_startDate = moment().add(1, 'weeks').isoWeekday(dayINeed).format("DD/MM/YYYY");
//}
//_startDate = moment().add(_startDate.getDay(), "days").format("DD/MM/YYYY");
_endDate = moment(_startDate, 'DD/MM/YYYY').add(7, "days").format("DD/MM/YYYY");
_currentDate = moment().format("DD/MM/YYYY");
}
console.log(_startDate);
$('#pickupSchedule').datepicker({
format: 'DD d MM yyyy',
startDate: _startDate,
autoclose: true,
language: 'fr',
orientation: "left bottom",
daysOfWeekDisabled: _daysOfWeekDisabled,
endDate: _endDate,
}).on('changeDate', function(e) {
var date = e.date;
var selected_date = moment(date).format("DD d MM yyyy");
var today_date = moment().format("DD d MM yyyy");
var tomorrow_date = moment().add(1, "day").format("DD d MM yyyy");
var is_tomorrow = false;
if (selected_date == tomorrow_date) {
is_tomorrow = true;
}
var dayOfWeek = date.getDay();
generateDateTimePicker(dayOfWeek, is_tomorrow);
});
$('#pickupScheduleHidden').val('');
$('#pickupSchedule').val('');
$('#datetime_picker').hide();
$('#dateTimePickerRow').hide();
pickupLocationScheduleDisplay();
});
/*$('#pickupScheduleCheckbox').change(function () {
if ($(this).prop('checked')) {
$('#customDelivery').hide();
$('#pickupAdressBlock').show();
$('#pickupSchedule').attr("disabled", false);
$('#action_bulkshipping').attr("disabled", true);
} else {
$('#pickupAdressBlock').hide();
$('#pickupSchedule').attr("disabled", true);
$('#action_bulkshipping').attr("disabled", false);
}
});
*/
});
$(document).ready(function () {
$('#newAddress_citySelectQC').select2({
ajax: {
delay: 250,
url: '{{ path('cityAdressAJAXSearch',{ 'province': 'QC'}) }}',
dataType: 'json'
},
"language": {
"noResults": function(){
return "Veuillez entrer le nom d'une ville...";
}
},
});
});
$(document).ready(function () {
$('#newAddress_citySelectON').select2({
ajax: {
delay: 250,
url: '{{ path('cityAdressAJAXSearch',{ 'province': 'ON'}) }}',
dataType: 'json'
},
"language": {
"noResults": function(){
return "Veuillez entrer le nom d'une ville d'ontario...";
}
},
});
});
</script>
<script>
</script>
<!-- Include Google Maps JS API -->
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?libraries=places&key=AIzaSyBpav0kc3zAMAcy7DhIto2hDhPivUCr3vI&langues=fr"></script>
<script>
// This sample uses the Places Autocomplete widget to:
// 1. Help the user select a place
// 2. Retrieve the address components associated with that place
// 3. Populate the form fields with those address components.
// This sample requires the Places library, Maps JavaScript API.
// Include the libraries=places parameter when you first load the API.
// For example: <script
// src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&libraries=places">
let autocomplete;
let address1Field;
let address2Field;
let postalField;
function initAutocomplete() {
address1Field = document.querySelector("#newAddress_autocomplete");
address2Field = document.querySelector("#newAddress_unit");
postalField = document.querySelector("#postal_code");
const center = { lat: 45.5333387, lng: -73.4200318 };
// Create a bounding box with sides ~10km away from the center point
const defaultBounds = {
north: center.lat + 0.5,
south: center.lat - 0.5,
east: center.lng + 0.5,
west: center.lng - 0.5,
};
// Create the autocomplete object, restricting the search predictions to
// addresses in the Canada.
autocomplete = new google.maps.places.Autocomplete(address1Field, {
componentRestrictions: { country: ["ca"] },
bounds: defaultBounds,
// fields: ["address_components", "geometry"],
types: ["address"],
});
address1Field.focus();
// When the user selects an address from the drop-down, populate the
// address fields in the form.
autocomplete.addListener("place_changed", fillInAddress);
}
function fillInAddress() {
// Get the place details from the autocomplete object.
const place = autocomplete.getPlace();
let address1 = "";
let postcode = "";
// Get each component of the address from the place details,
// and then fill-in the corresponding field on the form.
// place.address_components are google.maps.GeocoderAddressComponent objects
// which are documented at http://goo.gle/3l5i5Mr
for (const component of place.address_components) {
// @ts-ignore remove once typings fixed
const componentType = component.types[0];
switch (componentType) {
case "street_number": {
address1 = `${component.long_name} ${address1}`;
break;
}
case "route": {
address1 += component.long_name;
break;
}
case "postal_code": {
postcode = `${component.long_name}${postcode}`;
break;
}
case "postal_code_suffix": {
postcode = `${postcode}-${component.long_name}`;
break;
}
case "locality":
document.querySelector("#adresse_city").value = component.long_name;
break;
case "administrative_area_level_1": {
document.querySelector("#adresse_province").value = component.short_name;
break;
}
}
}
address1Field.value = address1;
postalField.value = postcode;
// After filling the form with address components from the Autocomplete
// prediction, set cursor focus on the second address line to encourage
// entry of subpremise information such as apartment, unit, or floor number.
address2Field.focus();
}
window.initAutocomplete = initAutocomplete;
{# function initializeAutocomplete(id) {
var element = document.getElementById(id);
const options = {
componentRestrictions: { country: "ca" },
types: ['address']
};
if (element) {
var autocomplete = new google.maps.places.Autocomplete(element, options);
google.maps.event.addListener(autocomplete, 'place_changed', onPlaceChanged);
}
} #}
function onPlaceChanged() {
var place = this.getPlace();
//console.log(place); // Uncomment this line to view the full object returned by Google API.
for (var i in place.address_components) {
var component = place.address_components[i];
for (var j in component.types) { // Some types are ["country", "political"]
var type_element = document.getElementById(component.types[j]);
if (type_element) {
type_element.value = component.long_name;
}
}
}
}
function googleMapsCustomError(){
alert('Google Maps custom error triggered');
}
(function takeOverConsole() { // taken from http://tobyho.com/2012/07/27/taking-over-console-log/
var console = window.console
if (!console) return
function intercept(method) {
var original = console[method]
console[method] = function() {
// check message
if(arguments[0] && arguments[0].indexOf('OverQuotaMapError') !== -1) {
googleMapsCustomError();
}
if (original.apply) {
// Do this for normal browsers
original.apply(console, arguments)
} else {
// Do this for IE
var message = Array.prototype.slice.apply(arguments).join(' ')
original(message)
}
}
}
var methods = ['error']; // only interested in the console.error method
for (var i = 0; i < methods.length; i++)
intercept(methods[i])
}())
window.gm_authFailure = function() {
// remove the map div or maybe call another API to load map
// maybe display a useful message to the user
document.getElementById('newAddress_autocomplete').id = 'newAddress';
var newInput = document.getElementById('newAddress');
newInput.name = 'newAddress';
newInput.classList.remove("pac-target-input");
newInput.classList.remove("gm-err-autocomplete");
newInput.style.removeProperty("background-image");
newInput.removeAttribute('disabled');
//alert('Google maps failed to load!');
}
google.maps.event.addDomListener(window, 'load', function() {
initAutocomplete('newAddress_autocomplete');
});
{# google.maps.event.addDomListener(window, 'load', function() {
initializeAutocomplete('newAddressGift_autocomplete');
}); #}
function SaveMyAdresse(e) {
if ($('#newAddress_autocomplete').val()){
var adresse_autocomplete = $('#newAddress_autocomplete').val();
}else{
var adresse_autocomplete = $('#newAddress').val();
}
//console.log(adresse_autocomplete);
var adresse_phone = $('#newAddress_phone').val();
var adresse_name = $('#newAddress_name').val();
if ($('#newAddress_unit').val()){
var adresse_unit = $('#newAddress_unit').val();
}
var adresse_zipcode = $('#postal_code').val();
var adresse_city = $('#adresse_city').val();
var adresse_province = $('#adresse_province').val();
//console.log(adresse_autocomplete);
if (!adresse_name){
document.getElementById("newAddress_name").style.border = "red solid 2px"
event.preventDefault();
event.stopImmediatePropagation();
return window.location = "#proceedToPaymentForm";
}
if (!adresse_phone){
document.getElementById("newAddress_phone").style.border = "red solid 2px"
event.preventDefault();
event.stopImmediatePropagation();
return window.location = "#proceedToPaymentForm";
}
if (!adresse_zipcode){
document.getElementById("postal_code").style.border = "red solid 2px"
event.preventDefault();
event.stopImmediatePropagation();
return window.location = "#proceedToPaymentForm";
}
if (!adresse_name){
document.getElementById("newAddress_name").style.border = "red solid 2px"
event.preventDefault();
event.stopImmediatePropagation();
return window.location = "#proceedToPaymentForm";
}
if (!adresse_city){
document.getElementById("adresse_city").style.border = "red solid 2px"
event.preventDefault();
event.stopImmediatePropagation();
return window.location = "#proceedToPaymentForm";
}
if (!adresse_province){
document.getElementById("adresse_province").style.border = "red solid 2px"
event.preventDefault();
event.stopImmediatePropagation();
return window.location = "#proceedToPaymentForm";
}
if (!adresse_autocomplete){
document.getElementById("newAddress_autocomplete").style.border = "red solid 2px"
event.preventDefault();
event.stopImmediatePropagation();
return window.location = "#proceedToPaymentForm";
}
$.ajax({
type: "POST",
url: '{{ path('SaveNewAdress',{ 'adresse': 'adresse'}) }}',
async: true,
data: {
adresse_autocomplete: $('#newAddress_autocomplete').val(),
adresse_manuel: $('#newAddress').val(),
adresse_phone: $('#newAddress_phone').val(),
adresse_name: $('#newAddress_name').val(),
adresse_unit : $('#newAddress_unit').val(),
adresse_zipcode : $('#postal_code').val(),
adresse_province : $('#adresse_province').val(),
adresse_city : $('#adresse_city').val(),
},
success: function () {
console.log('success');
location.reload(true)
}
});
};
</script>
{% endblock %}
{% block content %}
<form method="post" id="proceedToPaymentForm">
<input type="hidden" name="action" value="proceed_to_payment">
<!-- Page-Title -->
<div class="row">
<div class="col-lg-8 mx-auto">
<div class="row">
<div class="col-sm-12">
<p class="product-subtitle-brand">
<ul class="breadcrumb breadcrump-cart pull-right" >
<li>
<a href="{{path('viewCart')}}" class="">Panier</a>
</li>
<li>
<a href="{{path('checkout')}}" class="">
<u>Livraison / Cueillette</u>
</a>
</li>
<li>
<a href="{{path('cartPayment')}}" class="">Paiement</a>
</li>
<li>
<a href="{{path('home')}}" class="">Retour au magasin</a>
</li>
</ul>
</p>
</div>
</div>
{# <h1 class="text-primary text-center">PAGE TEST</h1> #}
<div class="card-box">
<h4 class=" checkoutBlocTitle">
Confirmez votre mode de livraison
</h4>
<div class="checkout-form d-flex">
{% set isAPickUp = global.getCart.getIsPickupOmeloView %}
<div id="checkShipping" class="py-3 pr-5" style="font-size: 18px;">
<input type="checkbox" value="domicile" class="choiceCustomShipping" {% if isAPickUp != 'Oui' %} checked="checked" {% endif %} name="action_shipping" id="action_shipping" />
<label for="action_shipping">Livraison à domicile</label>
</div>
<div id="checkPickUp" class="py-3 pr-5" style="font-size: 18px;">
<input type="checkbox" value="cueillette" class="choiceCustomShipping" {% if isAPickUp == 'Oui' %} checked="checked" {% endif %} id="pickupScheduleCheckbox" name="pickupScheduleCheckbox" />
<label for="pickupScheduleCheckbox">Point de cueillette</label>
</div>
{# <div id="checkGift" class="py-3" style="font-size: 18px;">
<input type="checkbox" value="cadeau" class="choiceCustomShipping" name="action_gift" id="action_gift" />
<label for="action_gift">Je veux faire un cadeau</label>
</div> #}
</div>
<!--end checkout-form-->
<div id="blocShipping" style="{% if isAPickUp != 'Oui' %}display:none;{% endif %}">
<h4 class="checkoutBlocTitle">
Entrez votre adresse :
</h4>
<div class="checkout-form">
{% set lastShippingAddress = global.getLastUsedShippingAddress %}
{% set lastShippingAddressId = 0 %}
{% if lastShippingAddress %}
{% set lastShippingAddressId = lastShippingAddress.id %}
{% endif %}
<select class="form-control {% if app.user.validShippingAddresses is empty %} d-none {% endif %}" id="checkoutAddressSelection" name="checkoutAddressSelection" style="font-size:15px">
<option value="none">Choisir une adresse existante ou entrer une nouvelle adresse</option>
{% for shippingAddress in app.user.validShippingAddresses %}
<option value="{{shippingAddress.id}}" {% if lastShippingAddressId == shippingAddress.id %} selected {% endif %}>{{shippingAddress}}</option>
{% endfor %}
</select>
<div id="add_new_address" class="m-t-20" style="{% if app.user.validShippingAddresses is not empty %}display:none;{% endif %}">
<h4 class="header-title mt-0 mb-3 {% if app.user.validShippingAddresses is empty %}d-none{% endif %}">
Nouvelle adresse
</h4>
<br/>
<div class="row">
<div class="col-md-8">
<label>Nom</label>
<input type="text" class="form-control" id="newAddress_name" name="newAddress_name">
</div>
<div class="col-md-4">
<label>Téléphone</label>
<input type="text" class="form-control" placeholder="(999) 999-9999" id="newAddress_phone" name="newAddress_phone">
{# <input type="tel" class="form-control" id="newAddress_phone" name="newAddress_phone" placeholder="9999999999" maxlength="15" required> #}
<script>
document.getElementById('newAddress_phone').addEventListener('input', function (e) {
var x = e.target.value.replace(/\D/g, '').match(/(\d{0,3})(\d{0,3})(\d{0,4})/);
e.target.value = !x[2] ? x[1] : '(' + x[1] + ') ' + x[2] + (x[3] ? '-' + x[3] : '');
});
</script>
</div>
</div>
<br/>
<div class="row">
<div class="col-md-8 col-lg-8">
<label>Veuillez entrer votre addresse</label>
<input type="text" class="form-control" placeholder="ex : 36 Rue Sainte-Catherine Ouest" id="newAddress_autocomplete" name="newAddress_autocomplete" autocomplete="off">
</div>
<div class="col-md-4">
<label>Unité</label>
<input type="text" class="form-control" placeholder="ex : Appartement/Unité/Batiment" id="newAddress_unit" name="newAddress_unit" maxlength="5">
</div>
</div>
<div class="row m-3">
{# <div class="col-md-4">
<label>province</label>
<input type="text" class="form-control" placeholder="" id="adresse_province" name="adresse_province" >
</div> #}
<div class="col-md-4">
<label>Province</label>
<select class="form-control" id="adresse_province" name="adresse_province">
<option value="QC">Québec</option>
<option value="AB">Alberta</option>
<option value="BC">Colombie-Britannique</option>
<option value="PE">Île-du-Prince-Édouard</option>
<option value="MB">Manitoba</option>
<option value="NB">Nouveau-Brunswick</option>
<option value="NS">Nouvelle-Écosse</option>
<option value="NU">Nunavut</option>
<option value="ON">Ontario</option>
<option value="SK">Saskatchewan</option>
<option value="NL">Terre-Neuve-et-Labrador</option>
<option value="NT">Territoires du Nord-Ouest</option>
<option value="YT">Yukon</option>
</select>
</div>
<div class="col-md-4">
<label>ville</label>
<input type="text" class="form-control" placeholder="" id="adresse_city" name="adresse_city">
</div>
{# <div class="col-md-4">
<label>Ville</label>
<div id="newAddress_cityQC">
<select class="form-control" id="newAddress_citySelectQC" name="newAddress_citySelectQC"></select>
</div>
<div id="newAddress_cityON" style="display:none;">
<select class="form-control" id="newAddress_citySelectON" name="newAddress_citySelectON"></select>
</div>
<div id="newAddress_cityAny" style="display:none;">
<input type="text" class="form-control" id="newAddress_cityInputAny" name="newAddress_cityInputAny">
</div>
</div> #}
<div class="col-md-4">
<label class="control-label">Code postal</label>
<input type="text" class="form-control" id="postal_code" name="newAddress_zipcode">
</div>
</div>
<div class="row" style="justify-content:end;">
<div class="col-md-3">
<input type="bouton" id="SaveAdress" value="Enregistrer" onClick="SaveMyAdresse()" class="btn-primary btn py-2 px-4"></input>
</div>
</div>
</div>
</div>
</div>
<div id="blocPickUp" style="display:none;">
{% if global.getAssociationUserIsBrowsing and
global.getAssociationUserIsBrowsing.getVariableByCodeName('orders.canPickUp') %}
<div class="checkout-form">
<div class=" mx-auto">
<h4 class="checkoutBlocTitle">
Cueillette au marche
</h4>
<div class="checkout-form">
<div class="row">
<div class="col-12">
<div class="form-group">
<label for="exampleFormControlSelect2">Addresse</label>
{% if global.getAssociationUserIsBrowsing.getVariableByCodeName('orders.pickUpAdress') %}
<input readonly type="text" class="form-control" value="{{ global.getAssociationUserIsBrowsing.getVariableByCodeName('orders.pickUpAdress').value }}">
{% else %}
<input readonly type="text" class="form-control" value="{{ global.getAssociationUserIsBrowsing.urlName}}">
{% endif %}
</div>
</div>
</div>
{# PICKUP SELECT : only avalaible for associations #}
<div class="row">
<div class="col-12">
{% set dayNameMap = ['Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi', 'Dimanche'] %}
<div class="form-group col-4">
{% if global.getAssociationUserIsBrowsing.getVariableByCodeName('orders.pickUpSchedule') %}
<label for="pickupScheduleChoice">Horaire de cueillette</label>
<select class="form-control" id="pickupScheduleChoice" name="pickupSchedule">
{% for schedule in global.pickupChoiceForCurrentAssociation %}
<option value="{{ schedule['day']|date("Y/m/d") }} de {{ schedule['start'] }} à {{ schedule['end'] }}">{{ dayNameMap[(schedule['day']|date("N"))-1] }}
{{
schedule['day']|date("d/m") }}
: de
{{ schedule['start'] }}
à
{{ schedule['end'] }}
</option>
{% endfor %}
</select>
{% else %}
<div class="col-4">
<label for="pickupScheduleChoice">Dites-nous quand comptez-vous venir :</label>
<input type="text" class="form-control col-4" name="pickupSchedule">
</div>
{% endif %}
</div>
</div>
</div>
{# PACKING SELECT : only avalaible for associations #}
{% if checkout.hasPickup %}
<div class="row">
<div class="col-12">
<div class="form-group">
<label for="withPackingChoice">Choix du type de ramassage</label>
<select class="form-control" id="withPackingChoice" name="withPacking">
{% if global.canPackup(checkout) > 0 %}
<option value="true">
Cueillette unique
{% if checkout.getPackingCost(false) > 0 %}: frais applicables de
{{
checkout.getPackingCost(false) }}$
{% endif %}
</option>
{% endif %}
{% if global.canPackup(checkout) != 1 %}
<option value="false">Cueillette aux kiosques</option>
{% endif %}
</select>
<br>
<ul>
<li>
<strong>Cueillette unique :</strong>
Votre commande sera préparée par notre marché et prête pour le ramassage
</li>
<li>
<strong>Cueillette aux kiosques :</strong>
Visitez chacun des exposants pour récupérer en kiosque les items de votre commande :
sans frais
</li>
</ul>
</div>
</div>
</div>
{% endif %}
</div>
<!--end checkout-form-->
</div>
<!--end col-->
</div>
<!--end row-->
{% else %}
{% if global.hasGlobalPickUpEnabled %}
{% set pickupSchedule = global.getGlobalPickUpSchedule %}
{% set pickupSchedules = global.getGlobalPickUpSchedules %}
{% set pickupLocation = global.getGlobalPickUpLocation %}
{% set pickupLocations = global.getGlobalPickUpLocations %}
{% if pickupSchedule %}
<script>
var pickupSchedule = '{{pickupSchedule|raw}}';
var pickupSchedules = '{{pickupSchedules|json_encode()|raw}}';
var pickupLocations = '{{pickupLocations|json_encode()|raw}}';
</script>
{% endif %}
<div class="checkout-form">
<div class=" mx-auto">
<div id="pickupAdressBlock" >
<h4 class="checkoutBlocTitle">
Cueillette en personne
</h4>
{# {% if app.user.getIsBetaTester %} #}
<div class="row my-2">
<div class="col-md-6">
<label>Nom</label>
<input type="text" class="form-control" id="pickup_name" required="" name="pickup_name" value="{{ app.user.firstname }}">
</div>
<div class="col-md-4">
<label>Téléphone</label>
<input type="text" class="form-control" placeholder="(999) 999-9999" required="" id="pickup_phone" name="pickup_phone" value="{{ app.user.phone }}">
<script>
document.getElementById('pickup_phone').addEventListener('input', function (e) {
var x = e.target.value.replace(/\D/g, '').match(/(\d{0,3})(\d{0,3})(\d{0,4})/);
e.target.value = !x[2] ? x[1] : '(' + x[1] + ') ' + x[2] + (x[3] ? '-' + x[3] : '');
});
</script>
</div>
</div>
{# {% endif %} #}
<div class="checkout-form">
<div class="row">
<div class="col-12">
<div class="form-group">
<label for="pickupLocations">Lieu de la cueillette</label>
<input type="hidden" name="pickupLocation" value="{{pickupLocation}}" id="pickupLocation">
<select class="form-control" name="pickupLocations" id="pickupLocations" style="overflow: scroll;">
<option value="" disabled SELECTED>--- Veuillez choisir le lieu de la cueillette ---</Option>
{% for pickupLocation in pickupLocations %}
<option value="{{pickupLocation.value}}">{{pickupLocation.text}}</option>
{% endfor %}
</select>
</div>
</div>
</div>
{# <hr/> #}
<div class="row" id="datetimeSelectionRow" style="display:none;">
<div class="col-12">
<div class="form-group">
<br/>
<label for="exampleFormControlSelect2">Horaire d'ouverture</label>
<div id="pickupLocationScheduleDisplay"></div>
<br/>
<div class="form-check">
<label for="pickupScheduleChoice">Dites-nous quand comptez-vous venir : <i class="fa fa-info-circle" ></i>
<div id="InfoPickUpChoice"><strong>Important :
</strong> Afin d'assurer la bonne préservation des aliments de votre boîte Maturin,
il est important d'aller chercher votre commande au point de cueillette le jour de la livraison.
</div>
</label>
<input type="text" readonly class="form-control" style="cursor:pointer;" placeholder="Cliquer ici pour choisir la date" id='pickupSchedule'>
<input type="hidden" id="pickupScheduleHidden" name="pickupSchedule">
</div>
<br/>
<div style="display:none;" id="datetime_picker">
<label for="pickupScheduleChoice">Dites-nous à quelle heure comptez-vous venir :</label>
<style>
.timepicker-hour-box {
border-radius:10px;
border:1px solid #ccc;
background-color: #eee;
padding: 10px;
cursor: pointer;
}
.timepicker-hour-box-disabled {
background-color: #666;
cursor: not-allowed;
}
.timepicker-selected {
background-color: green;
}
.timepicker-warning {
background-color: orange;
}
</style>
</div>
<div class="row" id="dateTimePickerRow">
</div>
</div>
</div>
</div>
</div>
</div>
<!--end checkout-form-->
</div>
<!--end col-->
</div>
<!--end row-->
{% endif %}
{% endif %}
</div>
</div>
</div>
</div>
<!--end card-box-->
<!--end col-->
<div id="choiceShippingDate">
<div class="row">
{% set dateDelivery = global.getCart.getDeliveryChoiceDate %}
<div class="col-lg-8 mx-auto">
<div class="text-center mb-3" id="deliveryEstimateSpinner">
<img src="/images/loading.gif" alt="Remplisser le formuliare avant de passer à la suite.">
</div>
<div class="card-box" id="deliveryEstimateCard">
<h4 class="checkoutBlocTitle">
Choisissez une date de livraison
</h4>
<p id="pChoiceDate" style="font-size:18px">Votre commande sera livrée le
<b id="defaultCustomDate" style="color:#53a321;">
{# {% if dateDelivery is null %} #}
<span id="evolutiveDateDelivery"> {{ dateDelivery| localizeddate('medium', 'none', null, '-7', 'l dd MMMM y') }}</span>
{#{% set route = global.getEstimationShippingRouteForMaturinProducts(global.getCart) %}
{% if route['route'] is not null and not route['route'].isPuro %}
{# {{route['date'] | localizeddate('medium', 'none', null, '-7', 'dd MMMM y')}} #}
{# {% else %} #}
{# entre {{route['date'] | localizeddate('medium', 'none', null, '-7', 'dd MMMM y')}}
et {{global.add48hToDate(route['date']) | localizeddate('medium', 'none', null, '-7', 'dd MMMM y')}} #}
{# {% endif %} #}
{# {% else %} #}
{# {% endif %} #}
entre 12h et 21h
</b>
</p>
<div class="form-check">
<input class="" type="checkbox" value="on" name="DeliveryCheck" id="DeliveryChoiceCheckbox"
{% if global.getCart.preOrder %}
checked
{% endif %}
>
<label class="form-check-label" for="flexCheckDefault" id="DateChoice" style="font-size:18px">
Choisir une autre date <i class="fa fa-info-circle"></i>
<div id="InfoDateChoice" class='m-2' style="font-size:18px">Vous pouvez choisir une date de livraison jusqu'à 8 semaines en avance</div>
</label>
<p/>
<div id="customDelivery" {% if dateDelivery is null %} style="display:none" {% endif %}>
{# Choisissez votre date: #}
<input type="text" class="form-control" placeholder="Cliquer ici pour choisir la date" style="font-size:18px" readonly name="livraisonDate" id="datepickerCustomDelivery">
</div>
</div>
<!--end checkout-form-->
</div>
<!--end card-box-->
</div>
</div>
<!--end col-->
</div>
<div id="blocGift" style="display:none;">
{#<div class="row">
<div class="col-lg-8 mx-auto">
<div class="card-box">
{{ block("content", "frontend/bulkshipModify.cart.html.twig") }}
</div>
</div>
</div>#}
<div class="row">
<div class="col-lg-8 mx-auto">
<div class="card-box">
<h4 class="checkoutBlocTitle">
Commande contenant un cadeau
</h4>
{# {% set display_bulkshipping_checkbox = true %}
{% if display_bulkshipping_checkbox %} #}
<div class="form-group">
<input type="checkbox" name="action_bulkshipping" id="action_bulkshipping">
<label for="action_bulkshipping" style="font-size:18px">Je veux faire un cadeau</label>
</div>
{# {% endif %} #}
<!--end checkout-form-->
</div>
<!--end card-box-->
</div>
<!--end col-->
</div>
</div>
{% if contains_alcohol %}
<div class="row">
<div class="col-lg-8 mx-auto">
<div class="card-box">
<h4 class="checkoutBlocTitle">
Âge requis pour acheter
</h4>
<div class="checkout-form">
<div class="row">
<div class="col-12">
<div class="form-group">
<input type="checkbox" name="18YearsOld">
<label for="exampleFormControlSelect2"> Je confirme avoir 18 ans et plus. </label>
</div>
</div>
</div>
<hr/>
<div class="row">
<div class="col-12">
<div class="form-group">
<p>L'alcool n’étant pas un produit comme les autres,
nous nous devons de faire respecter la loi relative à
la commercialisation de boissons alcooliques.</p>
<p>Cela exige que nous mettions tout en œuvre pour
nous assurer que nos produits sont vendus à des
personnes âgées de 18 ans ou plus.</p>
</div>
</div>
</div>
</div>
<!--end checkout-form-->
</div>
<!--end card-box-->
</div>
<!--end col-->
</div>
<!--end row-->
{% endif %}
<div class="row" >
<div class="col-lg-8 mx-auto">
<div class="card-box">
<h4 class="checkoutBlocTitle">
Coupon rabais
</h4>
<br/>
<div class="checkout-form">
{% if couponMarketing %}<p><a href="#" onclick="$('#coupon').val('{{coupon.code}}');">Coupon de <b>{{couponMarketing.amount }} $</b> ({{couponMarketing.code}})</a></p><br/>{% endif %}
{% for coupon in couponLists %}
{# {{ dump(date()|date("Y-m-d"))}} <= {{ dump(coupon.dateTo|date("Y-m-d"))}} #}
{% if date()|date("Y-m-d") <= coupon.dateTo|date("Y-m-d") %}
{% if coupon.type == 0 %}<p><a href="#" onclick="$('#coupon').val('{{coupon.code}}');" style="color : #53a321;">Coupon de <b>{{coupon.amount }} %</b> ({{coupon.code}})</a></p><br/>{% endif %}
{% if coupon.type == 2 %}<p><a href="#" onclick="$('#coupon').val('{{coupon.code}}');" style="color : #53a321;">Coupon de <b>{{coupon.amount }} $</b> ({{coupon.code}})</a></p><br/>{% endif %}
{% else %}
{% if coupon.type == 0 %}<p style="color : gray;">Coupon de <b>{{coupon.amount }} %</b> ({{coupon.code}}) (Expiré)</p><br/>{% endif %}
{% if coupon.type == 2 %}<p style="color : gray;">Coupon de <b>{{coupon.amount }} $</b> ({{coupon.code}}) (Expiré)</p><br/>{% endif %}
{% endif %}
{% endfor %}
{% set usedCouponCode = "" %}
{% if checkout.usedCoupon %}
{% set usedCouponCode = checkout.usedCoupon.code %}
{% endif %}
<input name="coupon" type="text" class="form-control" value="{{usedCouponCode}}" id="coupon" placeholder="Aucun coupon">
</div>
</div>
<!--end card-box-->
</div>
<!--end col-->
</div>
<!--end row-->
<div class="row">
<div class="col-lg-8 mx-auto">
{% if global.getAssociationUserIsBrowsing and
global.getAssociationUserIsBrowsing.getVariableByCodeName('orders.canPickUp') %}
{% set display_bulkshipping_checkbox = false %}
{% endif %}
<div style="width: 100%; text-align: right;">
{% if app.user.validShippingAddresses is empty %}
<button class="btn-primary btn py-2 px-4" name="proceedToPaymentSubmitBtn" id="proceedToPaymentSubmitBtn">Enregistrer et passer au paiement</button>
{% else %}
<button class="btn-primary btn py-2 px-4" name="proceedToPaymentSubmitBtn" id="proceedToPaymentSubmitBtn">Passer au paiement</button>
{% endif %}
</div>
</div>
<!--end col-->
</div>
<!--end row-->
</form>
{% endblock %}