Wprowadzenie drobnych poprawek i przekierowania ze strony order1 na place-order

This commit is contained in:
2024-01-18 08:10:53 +01:00
parent aee6659f67
commit 7c1c1b97dd
4 changed files with 83 additions and 32 deletions

View File

@@ -129,9 +129,18 @@ function loadMap() {
// Jesli nie ma informacji potrzebnej do mapy, zapisz wiadomosc do errora
let errorMessage = "";
if(!clientStreet) errorMessage += `${<iai:variable vid="Wpisz ulicę i numer domu klienta"/>} <br>`;
if(!clientZipCode) errorMessage += `${<iai:variable vid="Podaj kod pocztowy adresu dostawy"/>} <br>`;
if(!clientCity) errorMessage += `${<iai:variable vid="Wpisz miasto odbiorcy przesyłki"/>}`;
if(!clientStreet){
errorMessage += `${<iai:variable vid="Wpisz ulicę i numer domu klienta"/>} <br>`;
addErrorMessage(document.getElementById("client_street"), <iai:variable vid="Wpisz ulicę i numer domu klienta"/>)
}
if(!clientZipCode){
errorMessage += `${<iai:variable vid="Podaj kod pocztowy adresu dostawy"/>} <br>`;
addErrorMessage(document.getElementById("client_zipcode"), <iai:variable vid="Podaj kod pocztowy adresu dostawy"/>)
}
if(!clientCity){
errorMessage += `${<iai:variable vid="Wpisz miasto odbiorcy przesyłki"/>}`;
addErrorMessage(document.getElementById("client_city"), <iai:variable vid="Wpisz miasto odbiorcy przesyłki"/>)
}
// Zablokuj wybranie mapy jak nie ma adresu
if(errorMessage !== ""){
@@ -762,7 +771,7 @@ const SET_REGION = (setRegionInput) => JSON.stringify({
});
// Zmiana regionu dostawy
async function changeRegion(payAndDelData = null, firstLoad = false) {
async function changeRegion(payAndDelData = null) {
// Pobranie informacji o regionie z formularza
const clientRegion = document.getElementById("client_region").value;
const deliveryRegion = document.getElementById("deliver_to_billingaddr").checked ? document.getElementById("delivery_region").value : clientRegion;
@@ -780,11 +789,11 @@ async function changeRegion(payAndDelData = null, firstLoad = false) {
if (status !== 'success') return alert("Błąd podczas zmiany kraju. Przeładuj stronę jeszcze raz.");
// Pobranie nowych metod płatności i dostaw
getNewPaymentsAndDeliveries(payAndDelData, firstLoad);
getNewPaymentsAndDeliveries(payAndDelData);
};
// Załadowanie metod dostaw i płatności
function getNewPaymentsAndDeliveries(data = null, firstLoad = false) {
function getNewPaymentsAndDeliveries(data = null) {
// Wyczyszczenie zapisanych poprzednich metod płatności
prevPayment = undefined;
prevShipping = undefined;
@@ -823,6 +832,10 @@ function getNewPaymentsAndDeliveries(data = null, firstLoad = false) {
dvpMarkup += prepareDeliveryMarkup(method, deliveryId);
});
// Dane do zaznaczenia płatności i dostawy jeśli wcześniej na tej przeglądarce(localStorage) było już zamówienie
const prevOrderInfo = JSON.parse(localStorage.getItem("prevOrderInfo"));
console.log(prevOrderInfo);
// Wstawienie metod dostaw na strone
const deliveryMarkup = `<div id="osc_order1"><div id="osc_order1_prepaid" style="${paymentValue === "cash" ? "display:none;" : "display:block;"}">${prepaidMarkup}</div><div id="osc_order1_dvp" style="${paymentValue === "cash" ? "display:block;" : "display:none;"}">${dvpMarkup}</div></div>`;
const previousDeliveries = document.getElementById("osc_order1");
@@ -931,8 +944,8 @@ const checkedPayment = paymentValue === method.id;
if(!pointExists) selectedShipping.checked = false;
});
}// Sprawdzenie czy użytkownik ma zapisane poprzednio użyte metody w przeglądarce(tylko przy pierwszym załadowaniu strony)
else if(firstLoad && localStorage.getItem("prevCountry") && localStorage.getItem("prevCountry") === document.getElementById("client_region").value){
const prevPaymentMethod = JSON.parse(localStorage.getItem("prevPaymentMethod"));
else if(firstTimeLoadPage && prevOrderInfo && prevOrderInfo?.prevCountry === document.getElementById("client_region").value){
const prevPaymentMethod = prevOrderInfo.prevPaymentMethod;
// Zaznaczenie metod płatności które nie tworzą popupa
if(prevPaymentMethod.id !== "payitem_2" && prevPaymentMethod.group !== "card" && prevPaymentMethod.group !== "transfer"){
@@ -944,7 +957,7 @@ const checkedPayment = paymentValue === method.id;
}
// Poprzednia dostawa
const prevDeliveryMethod = JSON.parse(localStorage.getItem("prevDeliveryMethod"));
const prevDeliveryMethod = prevOrderInfo.prevDeliveryMethod;
const prevDeliveryInput = document.querySelector(`input#${prevDeliveryMethod.id}`);
// Sprawdzenie czy istnieje metoda dostawy (na wypadek gdyby była usunięta lub klient zamawiał do innego kraju)
@@ -982,6 +995,8 @@ const checkedPayment = paymentValue === method.id;
if(firstInput) deliveryDate(firstInput.value, firstInput.dataset.delivery, firstInput.dataset.pickuppoint);
calculateBasketCost();
app_shop.fn.ajaxLoadSite(0);
firstTimeLoadPage = false;
},
});
};
@@ -1874,9 +1889,13 @@ function sendOrder(data){
} : false
};
localStorage.setItem("prevPaymentMethod", JSON.stringify(usedPaymentMethod));
localStorage.setItem("prevDeliveryMethod", JSON.stringify(usedDeliveryMethod));
localStorage.setItem("prevCountry", usedCountry);
const prevOrderInfo = {
prevPaymentMethod: usedPaymentMethod,
prevDeliveryMethod: usedDeliveryMethod,
prevCountry: usedCountry
}
localStorage.setItem("prevOrderInfo", JSON.stringify(prevOrderInfo));
// Przeniesienie na stonę informacji o zamóieniu
window.location.href = e.location;
@@ -2047,11 +2066,12 @@ async function fetchData(options = {}) {
}
}
let firstTimeLoadPage = true;
function initOSCOP(){
// Element z numerem edycji jeśli jest
const editNumber = document.getElementById("edit-number");
if(document.querySelector(".ajax_cop").childElementCount && !editNumber) changeRegion(null, true);
if(document.querySelector(".ajax_cop").childElementCount && !editNumber) changeRegion(null);
// Jeśli edycja zamówienia uzupełnij dane (niewiadomo jak z voucherem bo go się nie da edytować)
if(editNumber){
@@ -2135,6 +2155,7 @@ if(editNumber){
// Pobranie danych o edytowanym zamówieniu
async function getEditData(){
const data = await fetchData({
data: ORDER_DETAILS(`OrderDetailsInput: {
orderNumber: ${editNumber.value},
@@ -2187,9 +2208,9 @@ if(editNumber){
// Metody płatności i dostaw
if(document.getElementById("delivery_region").value !== document.getElementById("client_region").value) changeRegion(orderData);
else getNewPaymentsAndDeliveries(orderData, true);
else getNewPaymentsAndDeliveries(orderData);
// Jeśli nie było dostawy na inny adres uzupełnij metody dostaw i płatności
}else getNewPaymentsAndDeliveries(orderData, true);
}else getNewPaymentsAndDeliveries(orderData);
// Uzupełnienie uwag dla sklepu/kuriera
if(orderDetails.remarks){

View File

@@ -1,9 +1,15 @@
// Zmiana linku po anulowaniu zamówienia;
setTimeout(function() {
if(window.location.pathname.includes("return.html") && window.location.search.includes("ordercancel_ok")){
const returnButtonInterval = setInterval(function() {
const returnPage = document.querySelector(".return_page");
const returnButton = document.querySelector("#retbut_ordercancel_ok");
if(returnPage && returnButton){
returnButton.href = returnButton.href.replace("&amp;order_number", "&order_number");
clearInterval(returnButtonInterval);
}
}, 50);
}, 100);
}
// Przekierowanie ze strony order1 na OSCOP
if(window.location.pathname.includes("order1.html")) window.location = "/place-order.php";

View File

@@ -51,6 +51,9 @@
.has-feedback.--error .form-control{
border-color: @less_iaicolorscheme_danger_color;
}
.has-feedback.--error.has-error .f-label{
color: @less_iaicolorscheme_danger_color;
}
// Zmiana fontsize na 16px na desktop
.order__voucher_headlines strong, .order__voucher_button, #signin-form-ajax .signin_button, .delivery__address-list-firstname, .delivery__address-list-lastname, .osc_item-modal h2, .propose_title, #e-invoice_dialog .btn, #checkout_step2_2 h3, #summary-points, #fbs_z02_wrapper .big_label, .propose_main .button_password_recover, .rebate__title{
font-size: 1.6rem!important;

View File

@@ -132,9 +132,18 @@ function loadMap() {
// Jesli nie ma informacji potrzebnej do mapy, zapisz wiadomosc do errora
let errorMessage = "";
if(!clientStreet) errorMessage += `${<iai:variable vid="Wpisz ulicę i numer domu klienta"/>} <br>`;
if(!clientZipCode) errorMessage += `${<iai:variable vid="Podaj kod pocztowy adresu dostawy"/>} <br>`;
if(!clientCity) errorMessage += `${<iai:variable vid="Wpisz miasto odbiorcy przesyłki"/>}`;
if(!clientStreet){
errorMessage += `${<iai:variable vid="Wpisz ulicę i numer domu klienta"/>} <br>`;
addErrorMessage(document.getElementById("client_street"), <iai:variable vid="Wpisz ulicę i numer domu klienta"/>)
}
if(!clientZipCode){
errorMessage += `${<iai:variable vid="Podaj kod pocztowy adresu dostawy"/>} <br>`;
addErrorMessage(document.getElementById("client_zipcode"), <iai:variable vid="Podaj kod pocztowy adresu dostawy"/>)
}
if(!clientCity){
errorMessage += `${<iai:variable vid="Wpisz miasto odbiorcy przesyłki"/>}`;
addErrorMessage(document.getElementById("client_city"), <iai:variable vid="Wpisz miasto odbiorcy przesyłki"/>)
}
// Zablokuj wybranie mapy jak nie ma adresu
if(errorMessage !== ""){
@@ -758,7 +767,7 @@ const SET_REGION = (setRegionInput) => JSON.stringify({
});
// Zmiana regionu dostawy
async function changeRegion(payAndDelData = null, firstLoad = false) {
async function changeRegion(payAndDelData = null) {
// Pobranie informacji o regionie z formularza
const clientRegion = document.getElementById("client_region").value;
const deliveryRegion = document.getElementById("deliver_to_billingaddr").checked ? document.getElementById("delivery_region").value : clientRegion;
@@ -776,11 +785,11 @@ async function changeRegion(payAndDelData = null, firstLoad = false) {
if (status !== 'success') return alert("Błąd podczas zmiany kraju. Przeładuj stronę jeszcze raz.");
// Pobranie nowych metod płatności i dostaw
getNewPaymentsAndDeliveries(payAndDelData, firstLoad);
getNewPaymentsAndDeliveries(payAndDelData);
};
// Załadowanie metod dostaw i płatności
function getNewPaymentsAndDeliveries(data = null, firstLoad = false) {
function getNewPaymentsAndDeliveries(data = null) {
// Wyczyszczenie zapisanych poprzednich metod płatności
prevPayment = undefined;
prevShipping = undefined;
@@ -819,6 +828,10 @@ function getNewPaymentsAndDeliveries(data = null, firstLoad = false) {
dvpMarkup += prepareDeliveryMarkup(method, deliveryId);
});
// Dane do zaznaczenia płatności i dostawy jeśli wcześniej na tej przeglądarce(localStorage) było już zamówienie
const prevOrderInfo = JSON.parse(localStorage.getItem("prevOrderInfo"));
console.log(prevOrderInfo);
// Wstawienie metod dostaw na strone
const deliveryMarkup = `<div id="osc_order1"><div id="osc_order1_prepaid" style="${paymentValue === "cash" ? "display:none;" : "display:block;"}">${prepaidMarkup}</div><div id="osc_order1_dvp" style="${paymentValue === "cash" ? "display:block;" : "display:none;"}">${dvpMarkup}</div></div>`;
const previousDeliveries = document.getElementById("osc_order1");
@@ -927,8 +940,8 @@ function getNewPaymentsAndDeliveries(data = null, firstLoad = 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)
else if(firstLoad && localStorage.getItem("prevCountry") && localStorage.getItem("prevCountry") === document.getElementById("client_region").value){
const prevPaymentMethod = JSON.parse(localStorage.getItem("prevPaymentMethod"));
else if(firstTimeLoadPage && prevOrderInfo && prevOrderInfo?.prevCountry === document.getElementById("client_region").value){
const prevPaymentMethod = prevOrderInfo.prevPaymentMethod;
// Zaznaczenie metod płatności które nie tworzą popupa
if(prevPaymentMethod.id !== "payitem_2" && prevPaymentMethod.group !== "card" && prevPaymentMethod.group !== "transfer"){
@@ -940,7 +953,7 @@ function getNewPaymentsAndDeliveries(data = null, firstLoad = false) {
}
// Poprzednia dostawa
const prevDeliveryMethod = JSON.parse(localStorage.getItem("prevDeliveryMethod"));
const prevDeliveryMethod = prevOrderInfo.prevDeliveryMethod;
const prevDeliveryInput = document.querySelector(`input#${prevDeliveryMethod.id}`);
// Sprawdzenie czy istnieje metoda dostawy (na wypadek gdyby była usunięta lub klient zamawiał do innego kraju)
@@ -978,6 +991,8 @@ function getNewPaymentsAndDeliveries(data = null, firstLoad = false) {
if(firstInput) deliveryDate(firstInput.value, firstInput.dataset.delivery, firstInput.dataset.pickuppoint);
calculateBasketCost();
app_shop.fn.ajaxLoadSite(0);
firstTimeLoadPage = false;
},
});
};
@@ -1870,9 +1885,13 @@ function sendOrder(data){
} : false
};
localStorage.setItem("prevPaymentMethod", JSON.stringify(usedPaymentMethod));
localStorage.setItem("prevDeliveryMethod", JSON.stringify(usedDeliveryMethod));
localStorage.setItem("prevCountry", usedCountry);
const prevOrderInfo = {
prevPaymentMethod: usedPaymentMethod,
prevDeliveryMethod: usedDeliveryMethod,
prevCountry: usedCountry
}
localStorage.setItem("prevOrderInfo", JSON.stringify(prevOrderInfo));
// Przeniesienie na stonę informacji o zamóieniu
window.location.href = e.location;
@@ -2043,11 +2062,12 @@ async function fetchData(options = {}) {
}
}
let firstTimeLoadPage = true;
function initOSCOP(){
// Element z numerem edycji jeśli jest
const editNumber = document.getElementById("edit-number");
if(document.querySelector(".ajax_cop").childElementCount && !editNumber) changeRegion(null, true);
if(document.querySelector(".ajax_cop").childElementCount && !editNumber) changeRegion(null);
// Jeśli edycja zamówienia uzupełnij dane (niewiadomo jak z voucherem bo go się nie da edytować)
if(editNumber){
@@ -2131,6 +2151,7 @@ function initOSCOP(){
// Pobranie danych o edytowanym zamówieniu
async function getEditData(){
const data = await fetchData({
data: ORDER_DETAILS(`OrderDetailsInput: {
orderNumber: ${editNumber.value},
@@ -2183,9 +2204,9 @@ function initOSCOP(){
// Metody płatności i dostaw
if(document.getElementById("delivery_region").value !== document.getElementById("client_region").value) changeRegion(orderData);
else getNewPaymentsAndDeliveries(orderData, true);
else getNewPaymentsAndDeliveries(orderData);
// Jeśli nie było dostawy na inny adres uzupełnij metody dostaw i płatności
}else getNewPaymentsAndDeliveries(orderData, true);
}else getNewPaymentsAndDeliveries(orderData);
// Uzupełnienie uwag dla sklepu/kuriera
if(orderDetails.remarks){