Wprowadzenie kraju ostatniego zamówienia do localStorage i sprawdzenie go przy uzupełnianiu danych o płatnościach i dostawie

This commit is contained in:
2024-01-16 13:09:02 +01:00
parent 8462d4932c
commit d3582a5c50
4 changed files with 107 additions and 38 deletions

View File

@@ -379,7 +379,7 @@
<iaixsl:attribute name="required">required</iaixsl:attribute> <iaixsl:attribute name="required">required</iaixsl:attribute>
</input> </input>
<label for="client_street" class="f-label"> <label for="client_street" class="f-label">
<iai:variable vid="Adres"/> <iai:variable vid="Ulica i numer"/>
</label> </label>
<span class="form-control-feedback"/> <span class="form-control-feedback"/>
</div> </div>
@@ -656,7 +656,7 @@
<iaixsl:attribute name="required">required</iaixsl:attribute> <iaixsl:attribute name="required">required</iaixsl:attribute>
</input> </input>
<label for="delivery_street" class="f-label"> <label for="delivery_street" class="f-label">
<iai:variable vid="Adres"/> <iai:variable vid="Ulica i numer"/>
</label> </label>
<span class="form-control-feedback"/> <span class="form-control-feedback"/>
</div> </div>
@@ -709,9 +709,19 @@
<iaixsl:attribute name="value"><iaixsl:value-of select="@id"/></iaixsl:attribute> <iaixsl:attribute name="value"><iaixsl:value-of select="@id"/></iaixsl:attribute>
<iaixsl:attribute name="data-vat_company"><iaixsl:value-of select="@vat_company"/></iaixsl:attribute> <iaixsl:attribute name="data-vat_company"><iaixsl:value-of select="@vat_company"/></iaixsl:attribute>
<iaixsl:attribute name="data-vat"><iaixsl:value-of select="@vat"/></iaixsl:attribute> <iaixsl:attribute name="data-vat"><iaixsl:value-of select="@vat"/></iaixsl:attribute>
<iaixsl:if test="(@id = /shop/page/client-data/delivery_data/@region) or (@id = /shop/page/options/countries/@delivery_active)"> <!--<iaixsl:if test="(@id = /shop/page/client-data/delivery_data/@region) or (@id = /shop/page/options/countries/@delivery_active)">-->
<iaixsl:attribute name="selected">selected</iaixsl:attribute> <!-- <iaixsl:attribute name="selected">selected</iaixsl:attribute>-->
</iaixsl:if> <!--</iaixsl:if>-->
<iaixsl:choose>
<iaixsl:when test="/shop/page/client-data/invoice_data/@region > 0">
<iaixsl:if test="@id = /shop/page/client-data/invoice_data/@region">
<iaixsl:attribute name="selected">selected</iaixsl:attribute>
</iaixsl:if>
</iaixsl:when>
<iaixsl:when test="@id = /shop/page/options/countries/@delivery_active">
<iaixsl:attribute name="selected">selected</iaixsl:attribute>
</iaixsl:when>
</iaixsl:choose>
<iaixsl:value-of select="@name"/> <iaixsl:value-of select="@name"/>
</option> </option>
</iaixsl:for-each> </iaixsl:for-each>

View File

@@ -4,23 +4,23 @@ var stocks_list_more_txt=<iai:variable vid="więcej informacji"/>;var stocks_lis
// Zmienna trzymająca informacje o customowych markerach // Zmienna trzymająca informacje o customowych markerach
// [wysokosc, szerokosc] w pikselach // [wysokosc, szerokosc] w pikselach
const defaultIconSize = [50,45]; const defaultMarkerSize = [50,45];
const mapMarkerIcons = { const mapMarkerIcons = {
inpost: L.icon({ inpost: L.icon({
iconUrl: "/data/include/deliveries/markers/inpost/marker_locker.png", iconUrl: "/data/include/deliveries/markers/inpost/marker_locker.png",
iconSize: defaultIconSize, iconSize: defaultMarkerSize,
className: "" className: ""
}), }),
default: L.icon({ default: L.icon({
iconUrl: "/gfx/standards/marker-icon.png", iconUrl: "/gfx/standards/marker-icon.png",
iconSize: defaultIconSize, iconSize: defaultMarkerSize,
className: "" className: ""
}), }),
// default: "/gfx/standards/marker-icon.png" // default: "/gfx/standards/marker-icon.png"
// custom : "/data/include/cms/map_marker/testMarkerIcon.svg?v=1703749620844" // custom : "/data/include/cms/map_marker/testMarkerIcon.svg?v=1703749620844"
orlen: L.icon({ orlen: L.icon({
iconUrl: "/data/include/deliveries/markers/paczkaOrlen/marker_orlen.png", iconUrl: "/data/include/deliveries/markers/paczkaOrlen/marker_orlen.png",
iconSize: defaultIconSize, iconSize: defaultMarkerSize,
className: "" className: ""
}), }),
} }
@@ -931,7 +931,7 @@ const checkedPayment = paymentValue === method.id;
if(!pointExists) selectedShipping.checked = false; if(!pointExists) selectedShipping.checked = false;
}); });
}// Sprawdzenie czy użytkownik ma zapisane poprzednio użyte metody w przeglądarce(tylko przy pierwszym załadowaniu strony) }// Sprawdzenie czy użytkownik ma zapisane poprzednio użyte metody w przeglądarce(tylko przy pierwszym załadowaniu strony)
else if(localStorage.getItem("prevPaymentMethod") && localStorage.getItem("prevDeliveryMethod") && firstLoad){ else if(firstLoad && localStorage.getItem("prevCountry") && localStorage.getItem("prevCountry") === document.getElementById("client_region").value){
const prevPaymentMethod = JSON.parse(localStorage.getItem("prevPaymentMethod")); const prevPaymentMethod = JSON.parse(localStorage.getItem("prevPaymentMethod"));
// Zaznaczenie metod płatności które nie tworzą popupa // Zaznaczenie metod płatności które nie tworzą popupa
@@ -1655,15 +1655,34 @@ document.querySelector(".order2_button_order").addEventListener("click", async (
// Przerwanie składania zamówienia jeśli w trakcie walidacji wystąpił błąd // Przerwanie składania zamówienia jeśli w trakcie walidacji wystąpił błąd
if (app_shop.vars.validation === 0) { if (app_shop.vars.validation === 0) {
// Scroll do elementów z błędem const errorEl = document.querySelector(".--error.has-error");
if(document.getElementById("order2_terms_conditions").checked && document.getElementById("order2_cancel").checked){ let scrolledToElement;
const errorEl = document.querySelector(".--error.has-error"); let alertMessage = "";
if(errorEl) scrollToHeight(errorEl)
else if(!document.querySelector(`input[name="payform_id"]:checked`)) scrollToHeight(document.querySelector("#checkout_step3_1 h2")); // Element sprawdzający czy regulamin jest zaznaczony
else if(!document.querySelector(`input[name="shipping"]:checked`)) scrollToHeight(document.querySelector("#checkout_step2_1 h2")); let termsAndConditions = document.getElementById("order2_terms_conditions").checked && document.getElementById("order2_cancel").checked;
if(!termsAndConditions) alertMessage += `${<iai:variable vid="Zatwierdź"/>} ${<iai:variable vid="Regulamin"/>}!<br/>`;
// Błąd w formularzu
if(errorEl){
scrolledToElement = errorEl;
alertMessage += `${<iai:variable vid="W formularzu wystąpiły błędy"/>}<br/>`;
}// Sprawdź metodę płatności i dostawy(scrollowanie do formularza ważniejsze)
if(!document.querySelector(`input[name="payform_id"]:checked`)){
scrolledToElement = errorEl || document.querySelector("#checkout_step3_1 h2");
alertMessage += `${<iai:variable vid="Proszę wybrać metodę płatności"/>}<br/>`;
} }
Alertek.show_alert(`${<iai:variable vid="W formularzu wystąpiły błędy"/>}`); if(!document.querySelector(`input[name="shipping"]:checked`)){
return app_shop.fn.ajaxLoadSite(0), !1; scrolledToElement = errorEl || document.querySelector("#checkout_step2_1 h2");
alertMessage += `${<iai:variable vid="Proszę wybrać dostępną metodę dostawy"/>}`;
}
// Jeśli użytkownik zatwierdził regulamin, przescrolluj do elementu z błędem
if(termsAndConditions) scrollToHeight(scrolledToElement);
// Pokaż error i przerwij składanie zamówienia
Alertek.show_alert(alertMessage);
return app_shop.fn.ajaxLoadSite(0);
} }
// Rejestracja użytkownika i/lub złożenie zamówienia // Rejestracja użytkownika i/lub złożenie zamówienia
@@ -1681,7 +1700,9 @@ document.querySelector(".order2_button_order").addEventListener("click", async (
}); });
// Przescrolluj do // Przescrolluj do
function scrollToHeight(scrollToEl){ function scrollToHeight(scrollToEl){
const yOffset = app_shop.vars.view === 1 ? -100 : -45; let yOffset = -45;
if(app_shop.vars.view === 1) yOffset = -100;
if(app_shop.vars.view === 2) yOffset = -75;
const y = scrollToEl.getBoundingClientRect().top + window.pageYOffset + yOffset; const y = scrollToEl.getBoundingClientRect().top + window.pageYOffset + yOffset;
window.scrollTo({top: y, behavior: 'smooth'}); window.scrollTo({top: y, behavior: 'smooth'});
} }
@@ -1839,6 +1860,8 @@ function sendOrder(data){
}, },
success: function (e) { success: function (e) {
if(e.location){ if(e.location){
// Zapisanie państwa żeby sprawdzić czy się zgadza
const usedCountry = document.getElementById("deliver_to_billingaddr").checked ? document.getElementById("delivery_region").value : document.getElementById("client_region").value;
// Zapisanie płatności i dostawy na następny raz // Zapisanie płatności i dostawy na następny raz
const paymentInput = document.querySelector(`input[name="payform_id"]:checked`) const paymentInput = document.querySelector(`input[name="payform_id"]:checked`)
const usedPaymentMethod = { const usedPaymentMethod = {
@@ -1863,6 +1886,7 @@ function sendOrder(data){
localStorage.setItem("prevPaymentMethod", JSON.stringify(usedPaymentMethod)); localStorage.setItem("prevPaymentMethod", JSON.stringify(usedPaymentMethod));
localStorage.setItem("prevDeliveryMethod", JSON.stringify(usedDeliveryMethod)); localStorage.setItem("prevDeliveryMethod", JSON.stringify(usedDeliveryMethod));
localStorage.setItem("prevCountry", usedCountry);
// Przeniesienie na stonę informacji o zamóieniu // Przeniesienie na stonę informacji o zamóieniu
window.location.href = e.location; window.location.href = e.location;

View File

@@ -1,4 +1,7 @@
.--place-order-page{ .--place-order-page{
#modal_placeholder{
display: none;
}
// Blokada przesuwania się text area // Blokada przesuwania się text area
textarea{ textarea{
resize: none; resize: none;
@@ -205,7 +208,7 @@
} }
} }
// MODAL BANKU I KARTY // MODAL BANKU I KARTY
.transfer__methods .payments-container, .card__methods .payments-container{ .osc_item-modal .payments-container{
margin-top: 2rem; margin-top: 2rem;
display: grid; display: grid;
grid-template-columns: repeat(3,1fr); grid-template-columns: repeat(3,1fr);
@@ -518,8 +521,8 @@
cursor: pointer; cursor: pointer;
display: flex; display: flex;
align-items: center; align-items: center;
top: 12%; top: 1px;
height: 75%; height: 36px;
background: #fff; background: #fff;
} }
#toggle_password:hover{ #toggle_password:hover{
@@ -561,7 +564,7 @@
margin-right: 0.5rem; margin-right: 0.5rem;
} }
} }
#modal_placeholder, .delivery__address-list-button{ .delivery__address-list-button{
padding: 1rem 3rem; padding: 1rem 3rem;
display: none; display: none;
} }
@@ -1005,6 +1008,9 @@
.register{ .register{
padding-top: 1.6rem; padding-top: 1.6rem;
padding-bottom: 1.4rem; padding-bottom: 1.4rem;
#toggle_password{
height: 43px!important;
}
} }
.client_new_social{ .client_new_social{
gap: 1.6rem!important; gap: 1.6rem!important;
@@ -1044,7 +1050,7 @@
#client_form{ #client_form{
margin-bottom: 2.4rem; margin-bottom: 2.4rem;
} }
.transfer__methods .payments-container, .card__methods .payments-container{ .osc_item-modal .payments-container{
grid-template-columns: 47% 47%; grid-template-columns: 47% 47%;
} }
#cop_seection2{ #cop_seection2{
@@ -1153,6 +1159,11 @@
align-items: flex-start!important; align-items: flex-start!important;
} }
} }
@media(max-width: 450px){
.osc_item-modal .payments-container{
grid-template-columns: 1fr;
}
}
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// LEAFLET MAP // LEAFLET MAP
// Znika powtórzenie // Znika powtórzenie

View File

@@ -7,23 +7,23 @@ var stocks_list_more_txt=<iai:variable vid="więcej informacji"/>;var stocks_lis
// Zmienna trzymająca informacje o customowych markerach // Zmienna trzymająca informacje o customowych markerach
// [wysokosc, szerokosc] w pikselach // [wysokosc, szerokosc] w pikselach
const defaultIconSize = [50,45]; const defaultMarkerSize = [50,45];
const mapMarkerIcons = { const mapMarkerIcons = {
inpost: L.icon({ inpost: L.icon({
iconUrl: "/data/include/deliveries/markers/inpost/marker_locker.png", iconUrl: "/data/include/deliveries/markers/inpost/marker_locker.png",
iconSize: defaultIconSize, iconSize: defaultMarkerSize,
className: "" className: ""
}), }),
default: L.icon({ default: L.icon({
iconUrl: "/gfx/standards/marker-icon.png", iconUrl: "/gfx/standards/marker-icon.png",
iconSize: defaultIconSize, iconSize: defaultMarkerSize,
className: "" className: ""
}), }),
// default: "/gfx/standards/marker-icon.png" // default: "/gfx/standards/marker-icon.png"
// custom : "/data/include/cms/map_marker/testMarkerIcon.svg?v=1703749620844" // custom : "/data/include/cms/map_marker/testMarkerIcon.svg?v=1703749620844"
orlen: L.icon({ orlen: L.icon({
iconUrl: "/data/include/deliveries/markers/paczkaOrlen/marker_orlen.png", iconUrl: "/data/include/deliveries/markers/paczkaOrlen/marker_orlen.png",
iconSize: defaultIconSize, iconSize: defaultMarkerSize,
className: "" className: ""
}), }),
} }
@@ -927,7 +927,7 @@ function getNewPaymentsAndDeliveries(data = null, firstLoad = false) {
if(!pointExists) selectedShipping.checked = false; if(!pointExists) selectedShipping.checked = false;
}); });
}// Sprawdzenie czy użytkownik ma zapisane poprzednio użyte metody w przeglądarce(tylko przy pierwszym załadowaniu strony) }// Sprawdzenie czy użytkownik ma zapisane poprzednio użyte metody w przeglądarce(tylko przy pierwszym załadowaniu strony)
else if(localStorage.getItem("prevPaymentMethod") && localStorage.getItem("prevDeliveryMethod") && firstLoad){ else if(firstLoad && localStorage.getItem("prevCountry") && localStorage.getItem("prevCountry") === document.getElementById("client_region").value){
const prevPaymentMethod = JSON.parse(localStorage.getItem("prevPaymentMethod")); const prevPaymentMethod = JSON.parse(localStorage.getItem("prevPaymentMethod"));
// Zaznaczenie metod płatności które nie tworzą popupa // Zaznaczenie metod płatności które nie tworzą popupa
@@ -1651,15 +1651,34 @@ document.querySelector(".order2_button_order").addEventListener("click", async (
// Przerwanie składania zamówienia jeśli w trakcie walidacji wystąpił błąd // Przerwanie składania zamówienia jeśli w trakcie walidacji wystąpił błąd
if (app_shop.vars.validation === 0) { if (app_shop.vars.validation === 0) {
// Scroll do elementów z błędem const errorEl = document.querySelector(".--error.has-error");
if(document.getElementById("order2_terms_conditions").checked && document.getElementById("order2_cancel").checked){ let scrolledToElement;
const errorEl = document.querySelector(".--error.has-error"); let alertMessage = "";
if(errorEl) scrollToHeight(errorEl)
else if(!document.querySelector(`input[name="payform_id"]:checked`)) scrollToHeight(document.querySelector("#checkout_step3_1 h2")); // Element sprawdzający czy regulamin jest zaznaczony
else if(!document.querySelector(`input[name="shipping"]:checked`)) scrollToHeight(document.querySelector("#checkout_step2_1 h2")); let termsAndConditions = document.getElementById("order2_terms_conditions").checked && document.getElementById("order2_cancel").checked;
if(!termsAndConditions) alertMessage += `${<iai:variable vid="Zatwierdź"/>} ${<iai:variable vid="Regulamin"/>}!<br/>`;
// Błąd w formularzu
if(errorEl){
scrolledToElement = errorEl;
alertMessage += `${<iai:variable vid="W formularzu wystąpiły błędy"/>}<br/>`;
}// Sprawdź metodę płatności i dostawy(scrollowanie do formularza ważniejsze)
if(!document.querySelector(`input[name="payform_id"]:checked`)){
scrolledToElement = errorEl || document.querySelector("#checkout_step3_1 h2");
alertMessage += `${<iai:variable vid="Proszę wybrać metodę płatności"/>}<br/>`;
} }
Alertek.show_alert(`${<iai:variable vid="W formularzu wystąpiły błędy"/>}`); if(!document.querySelector(`input[name="shipping"]:checked`)){
return app_shop.fn.ajaxLoadSite(0), !1; scrolledToElement = errorEl || document.querySelector("#checkout_step2_1 h2");
alertMessage += `${<iai:variable vid="Proszę wybrać dostępną metodę dostawy"/>}`;
}
// Jeśli użytkownik zatwierdził regulamin, przescrolluj do elementu z błędem
if(termsAndConditions) scrollToHeight(scrolledToElement);
// Pokaż error i przerwij składanie zamówienia
Alertek.show_alert(alertMessage);
return app_shop.fn.ajaxLoadSite(0);
} }
// Rejestracja użytkownika i/lub złożenie zamówienia // Rejestracja użytkownika i/lub złożenie zamówienia
@@ -1677,7 +1696,9 @@ document.querySelector(".order2_button_order").addEventListener("click", async (
}); });
// Przescrolluj do // Przescrolluj do
function scrollToHeight(scrollToEl){ function scrollToHeight(scrollToEl){
const yOffset = app_shop.vars.view === 1 ? -100 : -45; let yOffset = -45;
if(app_shop.vars.view === 1) yOffset = -100;
if(app_shop.vars.view === 2) yOffset = -75;
const y = scrollToEl.getBoundingClientRect().top + window.pageYOffset + yOffset; const y = scrollToEl.getBoundingClientRect().top + window.pageYOffset + yOffset;
window.scrollTo({top: y, behavior: 'smooth'}); window.scrollTo({top: y, behavior: 'smooth'});
} }
@@ -1835,6 +1856,8 @@ function sendOrder(data){
}, },
success: function (e) { success: function (e) {
if(e.location){ if(e.location){
// Zapisanie państwa żeby sprawdzić czy się zgadza
const usedCountry = document.getElementById("deliver_to_billingaddr").checked ? document.getElementById("delivery_region").value : document.getElementById("client_region").value;
// Zapisanie płatności i dostawy na następny raz // Zapisanie płatności i dostawy na następny raz
const paymentInput = document.querySelector(`input[name="payform_id"]:checked`) const paymentInput = document.querySelector(`input[name="payform_id"]:checked`)
const usedPaymentMethod = { const usedPaymentMethod = {
@@ -1859,6 +1882,7 @@ function sendOrder(data){
localStorage.setItem("prevPaymentMethod", JSON.stringify(usedPaymentMethod)); localStorage.setItem("prevPaymentMethod", JSON.stringify(usedPaymentMethod));
localStorage.setItem("prevDeliveryMethod", JSON.stringify(usedDeliveryMethod)); localStorage.setItem("prevDeliveryMethod", JSON.stringify(usedDeliveryMethod));
localStorage.setItem("prevCountry", usedCountry);
// Przeniesienie na stonę informacji o zamóieniu // Przeniesienie na stonę informacji o zamóieniu
window.location.href = e.location; window.location.href = e.location;