Usunięcie niektórych zmiennych globalnych

This commit is contained in:
2024-01-16 14:36:57 +01:00
parent 35afea715d
commit aee6659f67
2 changed files with 56 additions and 65 deletions

View File

@@ -33,7 +33,7 @@ function getMarkerIcon(courierId){
} }
// Zmienne trzymające id dostaw z mapą i czy mapa już była załadowana // Zmienne trzymające id dostaw z mapą i czy mapa już była załadowana
const deliveryPickupPoints = [] ; const deliveryPickupPoints = [];
let finpostjs = false; let finpostjs = false;
// Funkcja inicjująca mapę // Funkcja inicjująca mapę
function loadMap() { function loadMap() {
@@ -185,8 +185,7 @@ function loadMap() {
runSearchPickup(); runSearchPickup();
} }
if (!finpostjs) { if (!finpostjs) {
console.log("pickup_sites_list.js loaded"); finpostjs = true;
finpostjs = true;
pickup_sites.courierId = ITEM_ID; pickup_sites.courierId = ITEM_ID;
runSearchPickup(); runSearchPickup();
@@ -636,9 +635,10 @@ function handleShowSigninModalFromEmailModal(e){
} }
// EventListener zmian w kontenerze cop_seection1 // EventListener zmian w kontenerze cop_seection1
document.getElementById("cop_seection1").addEventListener("change", (e) => {
const validateRequestId = ["client_zipcode", "delivery_zipcode", "client_nip", "client_email"]; const validateRequestId = ["client_zipcode", "delivery_zipcode", "client_nip", "client_email"];
const notEmptyFieldsId = ["client_firstname", "client_lastname", "client_city", "delivery_firstname", "delivery_lastname", "delivery_city", "client_firm"]; const notEmptyFieldsId = ["client_firstname", "client_lastname", "client_city", "delivery_firstname", "delivery_lastname", "delivery_city", "client_firm"];
document.getElementById("cop_seection1").addEventListener("change", (e) => {
// Walidacja zipcode, nipu i emaila // Walidacja zipcode, nipu i emaila
if(validateRequestId.includes(e.target.id)) return validateRequest(e.target); if(validateRequestId.includes(e.target.id)) return validateRequest(e.target);
@@ -653,11 +653,14 @@ document.getElementById("cop_seection1").addEventListener("change", (e) => {
// Walidacja ulicy i numeru domu // Walidacja ulicy i numeru domu
if(e.target.id === "client_street" || e.target.id === "delivery_street") validateStreet(e.target); if(e.target.id === "client_street" || e.target.id === "delivery_street") validateStreet(e.target);
// Walidacja numeru telefonu // Walidacja numeru telefonu
if(e.target.id === "client_phone" || e.target.id === "delivery_phone") validatePhone(e.target); if(e.target.id === "client_phone" || e.target.id === "delivery_phone") validatePhone(e.target);
// Walidacja loginu i hasła rejestracji // Walidacja loginu i hasła rejestracji
if(e.target.classList.contains("register__login")) testLogin(); if(e.target.classList.contains("register__login")) testLogin();
if(e.target.classList.contains("register__password")) testPassword(); if(e.target.classList.contains("register__password")) testPassword();
// Walidacja imienia nazwiska miasta i firmy(wymagające po prostu nie bycia pustym) // Walidacja imienia nazwiska miasta i firmy(wymagające po prostu nie bycia pustym)
if(notEmptyFieldsId.includes(e.target.id)) validateNotEmpty(e.target); if(notEmptyFieldsId.includes(e.target.id)) validateNotEmpty(e.target);
@@ -667,6 +670,7 @@ document.getElementById("cop_seection1").addEventListener("change", (e) => {
else clearValidation(e.target); else clearValidation(e.target);
}; };
}); });
// Funkcje walidacji poszczególnych elementów // Funkcje walidacji poszczególnych elementów
function validateStreet(streetEl){ function validateStreet(streetEl){
const streetParts = streetEl.value.split(" "); const streetParts = streetEl.value.split(" ");
@@ -1296,16 +1300,10 @@ function handleClickVoucherSubmit(){
// Przeliczenie i pokazanie ceny w podsumowaniu // Przeliczenie i pokazanie ceny w podsumowaniu
let xhrs; let xhrs;
const productsWorthPriceEl = document.querySelector("#order2_products_worth .operation_value");
const deliveryCostEl = document.querySelector("#order2_shipping_value .operation_value");
const paymentCostEl = document.querySelector("#order2_paymentcost_value .operation_value");
const insuranceValueEl = document.querySelector("#order2_insurance_value .operation_value");
const totalRebateEl = document.querySelector("#order2_total_rebate .operation_value");
const saldoValueEl = document.querySelector("#order2_saldo_value .operation_value");
const productsPointsEl = document.querySelector("#order2_products_points .operation_value");
const summaryCostEl = document.getElementById("summary-cost");
const summaryPointsEl = document.getElementById("summary-points");
function calculateBasketCost() { function calculateBasketCost() {
const deliveryCostEl = document.querySelector("#order2_shipping_value .operation_value");
const productsPointsEl = document.querySelector("#order2_products_points .operation_value");
const summaryPointsEl = document.getElementById("summary-points");
// Przygotowanie informacji o metodzie dostawy i platnosci // Przygotowanie informacji o metodzie dostawy i platnosci
const orderInfo = { const orderInfo = {
delivery: document.querySelector('.ajax_cop input[name="shipping"]:checked') ? document.querySelector('.ajax_cop input[name="shipping"]:checked').value : "0-1", delivery: document.querySelector('.ajax_cop input[name="shipping"]:checked') ? document.querySelector('.ajax_cop input[name="shipping"]:checked').value : "0-1",
@@ -1317,7 +1315,7 @@ function calculateBasketCost() {
dataType: "json", dataType: "json",
data: orderInfo, data: orderInfo,
success: function (t) { success: function (t) {
productsWorthPriceEl.innerHTML = formatPrice(t.products_worth, t.currency_sign) + "<small>" + orderTxt.gross + "</small>"; document.querySelector("#order2_products_worth .operation_value").innerHTML = formatPrice(t.products_worth, t.currency_sign) + "<small>" + orderTxt.gross + "</small>";
// Sprawdź cene dostawy // Sprawdź cene dostawy
if(t.shipping_undefined) deliveryCostEl.parentElement.style.display = "none"; if(t.shipping_undefined) deliveryCostEl.parentElement.style.display = "none";
@@ -1334,10 +1332,10 @@ function calculateBasketCost() {
deliveryCostEl.classList.add("cost_free"); deliveryCostEl.classList.add("cost_free");
} }
} }
checkShowPrice(paymentCostEl, Number(t.prepaid_cost), t.currency_sign); checkShowPrice(document.querySelector("#order2_paymentcost_value .operation_value"), Number(t.prepaid_cost), t.currency_sign);
checkShowPrice(insuranceValueEl, Number(t.insurance_cost), t.currency_sign); checkShowPrice(document.querySelector("#order2_insurance_value .operation_value"), Number(t.insurance_cost), t.currency_sign);
checkShowPrice(totalRebateEl, Number(t.total_rebate_without_shipping), t.currency_sign); checkShowPrice(document.querySelector("#order2_total_rebate .operation_value"), Number(t.total_rebate_without_shipping), t.currency_sign);
checkShowPrice(saldoValueEl, Number(t.payment_amount_from_client_balance), t.currency_sign); checkShowPrice(document.querySelector("#order2_saldo_value .operation_value"), Number(t.payment_amount_from_client_balance), t.currency_sign);
// Punkty zamówienia // Punkty zamówienia
if(t.products_worth_at_points){ if(t.products_worth_at_points){
@@ -1351,7 +1349,7 @@ function calculateBasketCost() {
} }
// Cena całkowita // Cena całkowita
summaryCostEl.innerHTML = formatPrice(t.total_to_pay, t.currency_sign) + "<small>" + <iai:variable vid="brutto"/> + "</small>"; document.getElementById("summary-cost").innerHTML = formatPrice(t.total_to_pay, t.currency_sign) + "<small>" + <iai:variable vid="brutto"/> + "</small>";
}, },
}); });
}; };
@@ -1369,9 +1367,9 @@ function formatPrice(price, currencySign) {
}; };
// Funkcja od ustalenia daty dostawy // Funkcja od ustalenia daty dostawy
function deliveryDate(deliveryVal, delivery, pickuppoint) {
const deliveryMessageEl = document.querySelector("#order2_shiptime span:not(.operation_value)"); const deliveryMessageEl = document.querySelector("#order2_shiptime span:not(.operation_value)");
const deliveryDateEl = document.querySelector("#order2_shiptime .operation_value"); const deliveryDateEl = document.querySelector("#order2_shiptime .operation_value");
function deliveryDate(deliveryVal, delivery, pickuppoint) {
const date = delivery.split("#"); const date = delivery.split("#");
// Wybranie nazwy zaleznie czy dostawa jest do twojego mieszkania czy nie // Wybranie nazwy zaleznie czy dostawa jest do twojego mieszkania czy nie
@@ -1386,8 +1384,8 @@ function deliveryDate(deliveryVal, delivery, pickuppoint) {
}; };
// Obsługa klilnięć na elementy w podsumowaniu // Obsługa klilnięć na elementy w podsumowaniu
const productsContainer = document.getElementById("checkout_step3_3");
document.getElementById("cop_seection3").addEventListener("click", (e) => { document.getElementById("cop_seection3").addEventListener("click", (e) => {
const productsContainer = document.getElementById("checkout_step3_3");
// Kliknięcie na przyciski "Pokaż pozozostałe produkty" i "Zwiń listę" // Kliknięcie na przyciski "Pokaż pozozostałe produkty" i "Zwiń listę"
const togggleProducts = e.target.closest(".order_products_action"); const togggleProducts = e.target.closest(".order_products_action");
@@ -1514,12 +1512,9 @@ async function removeCode(){
} }
// Zmień widoczność kodu rabatowego // Zmień widoczność kodu rabatowego
const rebateOptionWrapper = document.querySelector(".rebate__options");
const rebateCodeContainer = document.querySelector(".rebate__code"); const rebateCodeContainer = document.querySelector(".rebate__code");
const rebateActiveWrapper = document.querySelector(".rebate__active");
const activeCodeEl = document.getElementById("active-code");
const rebateOptionEl = document.getElementById("rebate_option");
function toggleActiveCode(show, error=false){ function toggleActiveCode(show, error=false){
const activeCodeEl = document.getElementById("active-code");
// Wyczyść walidacje // Wyczyść walidacje
if(!error){ if(!error){
removeErrorMessage(rebateCode); removeErrorMessage(rebateCode);
@@ -1527,8 +1522,8 @@ function toggleActiveCode(show, error=false){
} }
// Zmień widoczność // Zmień widoczność
rebateOptionWrapper.style.display = show ? "none" : "flex"; document.querySelector(".rebate__options").style.display = show ? "none" : "flex";
rebateActiveWrapper.style.display = show ? "block" : "none"; document.querySelector(".rebate__active").style.display = show ? "block" : "none";
if(!error) rebateCodeContainer.classList.remove("--fade-in"); if(!error) rebateCodeContainer.classList.remove("--fade-in");
else rebateCodeContainer.classList.add("--fade-in"); else rebateCodeContainer.classList.add("--fade-in");
@@ -1536,15 +1531,14 @@ function toggleActiveCode(show, error=false){
// Zmień wartości // Zmień wartości
activeCodeEl.innerHTML = show ? rebateCode.value : ""; activeCodeEl.innerHTML = show ? rebateCode.value : "";
showInput = error ? true : false; showInput = error ? true : false;
rebateOptionEl.checked = error ? true : false; document.getElementById("rebate_option").checked = error ? true : false;
if(!error) rebateCode.value = ""; if(!error) rebateCode.value = "";
else activeCodeEl.innerHTML = ""; else activeCodeEl.innerHTML = "";
} }
// EventListenery dla kodu rabatowego // EventListenery dla kodu rabatowego
let showInput = false; let showInput = false;
const rebateCodeWrapper = document.querySelector(".rebate"); document.querySelector(".rebate").addEventListener("click", (e) => {
rebateCodeWrapper.addEventListener("click", (e) => {
// Rozwinięcie opcji rabatowej // Rozwinięcie opcji rabatowej
if(e.target.id === "rebate_option" || e.target.classList.contains("rebate__active_change")){ if(e.target.id === "rebate_option" || e.target.classList.contains("rebate__active_change")){
showInput = !showInput; showInput = !showInput;
@@ -1608,9 +1602,9 @@ async function validateFormInputs(query){
} }
// Obsługa złożenia zamówienia // Obsługa złożenia zamówienia
document.querySelector(".order2_button_order").addEventListener("click", async () => {
const termsConditionsInput = document.getElementById("order2_terms_conditions"); const termsConditionsInput = document.getElementById("order2_terms_conditions");
const cancelConditionsInput = document.getElementById("order2_cancel"); const cancelConditionsInput = document.getElementById("order2_cancel");
document.querySelector(".order2_button_order").addEventListener("click", async () => {
try { try {
app_shop.fn.ajaxLoadSite(1); app_shop.fn.ajaxLoadSite(1);
app_shop.vars.validation = 1; app_shop.vars.validation = 1;
@@ -1656,7 +1650,7 @@ document.querySelector(".order2_button_order").addEventListener("click", async (
let alertMessage = ""; let alertMessage = "";
// Element sprawdzający czy regulamin jest zaznaczony // Element sprawdzający czy regulamin jest zaznaczony
let termsAndConditions = document.getElementById("order2_terms_conditions").checked && document.getElementById("order2_cancel").checked; let termsAndConditions = termsConditionsInput.checked && cancelConditionsInput.checked;
if(!termsAndConditions) alertMessage += `${<iai:variable vid="Zatwierdź"/>} ${<iai:variable vid="Regulamin"/>}!<br/>`; if(!termsAndConditions) alertMessage += `${<iai:variable vid="Zatwierdź"/>} ${<iai:variable vid="Regulamin"/>}!<br/>`;
// Błąd w formularzu // Błąd w formularzu
if(errorEl){ if(errorEl){
@@ -1842,6 +1836,7 @@ function checkNewsletter(logged, regular){
else if(document.querySelector(regular)) return document.querySelector(regular).checked ? 1 : 0; else if(document.querySelector(regular)) return document.querySelector(regular).checked ? 1 : 0;
else return 0; else return 0;
} }
// Funkcja wysyłająca zamówienie // Funkcja wysyłająca zamówienie
function sendOrder(data){ function sendOrder(data){
$.ajax({ $.ajax({

View File

@@ -36,7 +36,7 @@ function getMarkerIcon(courierId){
} }
// Zmienne trzymające id dostaw z mapą i czy mapa już była załadowana // Zmienne trzymające id dostaw z mapą i czy mapa już była załadowana
const deliveryPickupPoints = [] ; const deliveryPickupPoints = [];
let finpostjs = false; let finpostjs = false;
// Funkcja inicjująca mapę // Funkcja inicjująca mapę
function loadMap() { function loadMap() {
@@ -631,9 +631,10 @@ function handleShowSigninModalFromEmailModal(e){
} }
// EventListener zmian w kontenerze cop_seection1 // EventListener zmian w kontenerze cop_seection1
const validateRequestId = ["client_zipcode", "delivery_zipcode", "client_nip", "client_email"];
const notEmptyFieldsId = ["client_firstname", "client_lastname", "client_city", "delivery_firstname", "delivery_lastname", "delivery_city", "client_firm"];
document.getElementById("cop_seection1").addEventListener("change", (e) => { document.getElementById("cop_seection1").addEventListener("change", (e) => {
const validateRequestId = ["client_zipcode", "delivery_zipcode", "client_nip", "client_email"];
const notEmptyFieldsId = ["client_firstname", "client_lastname", "client_city", "delivery_firstname", "delivery_lastname", "delivery_city", "client_firm"];
// Walidacja zipcode, nipu i emaila // Walidacja zipcode, nipu i emaila
if(validateRequestId.includes(e.target.id)) return validateRequest(e.target); if(validateRequestId.includes(e.target.id)) return validateRequest(e.target);
@@ -648,11 +649,14 @@ document.getElementById("cop_seection1").addEventListener("change", (e) => {
// Walidacja ulicy i numeru domu // Walidacja ulicy i numeru domu
if(e.target.id === "client_street" || e.target.id === "delivery_street") validateStreet(e.target); if(e.target.id === "client_street" || e.target.id === "delivery_street") validateStreet(e.target);
// Walidacja numeru telefonu // Walidacja numeru telefonu
if(e.target.id === "client_phone" || e.target.id === "delivery_phone") validatePhone(e.target); if(e.target.id === "client_phone" || e.target.id === "delivery_phone") validatePhone(e.target);
// Walidacja loginu i hasła rejestracji // Walidacja loginu i hasła rejestracji
if(e.target.classList.contains("register__login")) testLogin(); if(e.target.classList.contains("register__login")) testLogin();
if(e.target.classList.contains("register__password")) testPassword(); if(e.target.classList.contains("register__password")) testPassword();
// Walidacja imienia nazwiska miasta i firmy(wymagające po prostu nie bycia pustym) // Walidacja imienia nazwiska miasta i firmy(wymagające po prostu nie bycia pustym)
if(notEmptyFieldsId.includes(e.target.id)) validateNotEmpty(e.target); if(notEmptyFieldsId.includes(e.target.id)) validateNotEmpty(e.target);
@@ -662,6 +666,7 @@ document.getElementById("cop_seection1").addEventListener("change", (e) => {
else clearValidation(e.target); else clearValidation(e.target);
}; };
}); });
// Funkcje walidacji poszczególnych elementów // Funkcje walidacji poszczególnych elementów
function validateStreet(streetEl){ function validateStreet(streetEl){
const streetParts = streetEl.value.split(" "); const streetParts = streetEl.value.split(" ");
@@ -1291,16 +1296,10 @@ function handleClickVoucherSubmit(){
// Przeliczenie i pokazanie ceny w podsumowaniu // Przeliczenie i pokazanie ceny w podsumowaniu
let xhrs; let xhrs;
const productsWorthPriceEl = document.querySelector("#order2_products_worth .operation_value");
const deliveryCostEl = document.querySelector("#order2_shipping_value .operation_value");
const paymentCostEl = document.querySelector("#order2_paymentcost_value .operation_value");
const insuranceValueEl = document.querySelector("#order2_insurance_value .operation_value");
const totalRebateEl = document.querySelector("#order2_total_rebate .operation_value");
const saldoValueEl = document.querySelector("#order2_saldo_value .operation_value");
const productsPointsEl = document.querySelector("#order2_products_points .operation_value");
const summaryCostEl = document.getElementById("summary-cost");
const summaryPointsEl = document.getElementById("summary-points");
function calculateBasketCost() { function calculateBasketCost() {
const deliveryCostEl = document.querySelector("#order2_shipping_value .operation_value");
const productsPointsEl = document.querySelector("#order2_products_points .operation_value");
const summaryPointsEl = document.getElementById("summary-points");
// Przygotowanie informacji o metodzie dostawy i platnosci // Przygotowanie informacji o metodzie dostawy i platnosci
const orderInfo = { const orderInfo = {
delivery: document.querySelector('.ajax_cop input[name="shipping"]:checked') ? document.querySelector('.ajax_cop input[name="shipping"]:checked').value : "0-1", delivery: document.querySelector('.ajax_cop input[name="shipping"]:checked') ? document.querySelector('.ajax_cop input[name="shipping"]:checked').value : "0-1",
@@ -1312,7 +1311,7 @@ function calculateBasketCost() {
dataType: "json", dataType: "json",
data: orderInfo, data: orderInfo,
success: function (t) { success: function (t) {
productsWorthPriceEl.innerHTML = formatPrice(t.products_worth, t.currency_sign) + "<small>" + orderTxt.gross + "</small>"; document.querySelector("#order2_products_worth .operation_value").innerHTML = formatPrice(t.products_worth, t.currency_sign) + "<small>" + orderTxt.gross + "</small>";
// Sprawdź cene dostawy // Sprawdź cene dostawy
if(t.shipping_undefined) deliveryCostEl.parentElement.style.display = "none"; if(t.shipping_undefined) deliveryCostEl.parentElement.style.display = "none";
@@ -1329,10 +1328,10 @@ function calculateBasketCost() {
deliveryCostEl.classList.add("cost_free"); deliveryCostEl.classList.add("cost_free");
} }
} }
checkShowPrice(paymentCostEl, Number(t.prepaid_cost), t.currency_sign); checkShowPrice(document.querySelector("#order2_paymentcost_value .operation_value"), Number(t.prepaid_cost), t.currency_sign);
checkShowPrice(insuranceValueEl, Number(t.insurance_cost), t.currency_sign); checkShowPrice(document.querySelector("#order2_insurance_value .operation_value"), Number(t.insurance_cost), t.currency_sign);
checkShowPrice(totalRebateEl, Number(t.total_rebate_without_shipping), t.currency_sign); checkShowPrice(document.querySelector("#order2_total_rebate .operation_value"), Number(t.total_rebate_without_shipping), t.currency_sign);
checkShowPrice(saldoValueEl, Number(t.payment_amount_from_client_balance), t.currency_sign); checkShowPrice(document.querySelector("#order2_saldo_value .operation_value"), Number(t.payment_amount_from_client_balance), t.currency_sign);
// Punkty zamówienia // Punkty zamówienia
if(t.products_worth_at_points){ if(t.products_worth_at_points){
@@ -1346,7 +1345,7 @@ function calculateBasketCost() {
} }
// Cena całkowita // Cena całkowita
summaryCostEl.innerHTML = formatPrice(t.total_to_pay, t.currency_sign) + "<small>" + <iai:variable vid="brutto"/> + "</small>"; document.getElementById("summary-cost").innerHTML = formatPrice(t.total_to_pay, t.currency_sign) + "<small>" + <iai:variable vid="brutto"/> + "</small>";
}, },
}); });
}; };
@@ -1364,9 +1363,9 @@ function formatPrice(price, currencySign) {
}; };
// Funkcja od ustalenia daty dostawy // Funkcja od ustalenia daty dostawy
const deliveryMessageEl = document.querySelector("#order2_shiptime span:not(.operation_value)");
const deliveryDateEl = document.querySelector("#order2_shiptime .operation_value");
function deliveryDate(deliveryVal, delivery, pickuppoint) { function deliveryDate(deliveryVal, delivery, pickuppoint) {
const deliveryMessageEl = document.querySelector("#order2_shiptime span:not(.operation_value)");
const deliveryDateEl = document.querySelector("#order2_shiptime .operation_value");
const date = delivery.split("#"); const date = delivery.split("#");
// Wybranie nazwy zaleznie czy dostawa jest do twojego mieszkania czy nie // Wybranie nazwy zaleznie czy dostawa jest do twojego mieszkania czy nie
@@ -1381,8 +1380,8 @@ function deliveryDate(deliveryVal, delivery, pickuppoint) {
}; };
// Obsługa klilnięć na elementy w podsumowaniu // Obsługa klilnięć na elementy w podsumowaniu
const productsContainer = document.getElementById("checkout_step3_3");
document.getElementById("cop_seection3").addEventListener("click", (e) => { document.getElementById("cop_seection3").addEventListener("click", (e) => {
const productsContainer = document.getElementById("checkout_step3_3");
// Kliknięcie na przyciski "Pokaż pozozostałe produkty" i "Zwiń listę" // Kliknięcie na przyciski "Pokaż pozozostałe produkty" i "Zwiń listę"
const togggleProducts = e.target.closest(".order_products_action"); const togggleProducts = e.target.closest(".order_products_action");
@@ -1509,12 +1508,9 @@ async function removeCode(){
} }
// Zmień widoczność kodu rabatowego // Zmień widoczność kodu rabatowego
const rebateOptionWrapper = document.querySelector(".rebate__options");
const rebateCodeContainer = document.querySelector(".rebate__code"); const rebateCodeContainer = document.querySelector(".rebate__code");
const rebateActiveWrapper = document.querySelector(".rebate__active");
const activeCodeEl = document.getElementById("active-code");
const rebateOptionEl = document.getElementById("rebate_option");
function toggleActiveCode(show, error=false){ function toggleActiveCode(show, error=false){
const activeCodeEl = document.getElementById("active-code");
// Wyczyść walidacje // Wyczyść walidacje
if(!error){ if(!error){
removeErrorMessage(rebateCode); removeErrorMessage(rebateCode);
@@ -1522,8 +1518,8 @@ function toggleActiveCode(show, error=false){
} }
// Zmień widoczność // Zmień widoczność
rebateOptionWrapper.style.display = show ? "none" : "flex"; document.querySelector(".rebate__options").style.display = show ? "none" : "flex";
rebateActiveWrapper.style.display = show ? "block" : "none"; document.querySelector(".rebate__active").style.display = show ? "block" : "none";
if(!error) rebateCodeContainer.classList.remove("--fade-in"); if(!error) rebateCodeContainer.classList.remove("--fade-in");
else rebateCodeContainer.classList.add("--fade-in"); else rebateCodeContainer.classList.add("--fade-in");
@@ -1531,15 +1527,14 @@ function toggleActiveCode(show, error=false){
// Zmień wartości // Zmień wartości
activeCodeEl.innerHTML = show ? rebateCode.value : ""; activeCodeEl.innerHTML = show ? rebateCode.value : "";
showInput = error ? true : false; showInput = error ? true : false;
rebateOptionEl.checked = error ? true : false; document.getElementById("rebate_option").checked = error ? true : false;
if(!error) rebateCode.value = ""; if(!error) rebateCode.value = "";
else activeCodeEl.innerHTML = ""; else activeCodeEl.innerHTML = "";
} }
// EventListenery dla kodu rabatowego // EventListenery dla kodu rabatowego
let showInput = false; let showInput = false;
const rebateCodeWrapper = document.querySelector(".rebate"); document.querySelector(".rebate").addEventListener("click", (e) => {
rebateCodeWrapper.addEventListener("click", (e) => {
// Rozwinięcie opcji rabatowej // Rozwinięcie opcji rabatowej
if(e.target.id === "rebate_option" || e.target.classList.contains("rebate__active_change")){ if(e.target.id === "rebate_option" || e.target.classList.contains("rebate__active_change")){
showInput = !showInput; showInput = !showInput;
@@ -1603,9 +1598,9 @@ async function validateFormInputs(query){
} }
// Obsługa złożenia zamówienia // Obsługa złożenia zamówienia
const termsConditionsInput = document.getElementById("order2_terms_conditions");
const cancelConditionsInput = document.getElementById("order2_cancel");
document.querySelector(".order2_button_order").addEventListener("click", async () => { document.querySelector(".order2_button_order").addEventListener("click", async () => {
const termsConditionsInput = document.getElementById("order2_terms_conditions");
const cancelConditionsInput = document.getElementById("order2_cancel");
try { try {
app_shop.fn.ajaxLoadSite(1); app_shop.fn.ajaxLoadSite(1);
app_shop.vars.validation = 1; app_shop.vars.validation = 1;
@@ -1651,7 +1646,7 @@ document.querySelector(".order2_button_order").addEventListener("click", async (
let alertMessage = ""; let alertMessage = "";
// Element sprawdzający czy regulamin jest zaznaczony // Element sprawdzający czy regulamin jest zaznaczony
let termsAndConditions = document.getElementById("order2_terms_conditions").checked && document.getElementById("order2_cancel").checked; let termsAndConditions = termsConditionsInput.checked && cancelConditionsInput.checked;
if(!termsAndConditions) alertMessage += `${<iai:variable vid="Zatwierdź"/>} ${<iai:variable vid="Regulamin"/>}!<br/>`; if(!termsAndConditions) alertMessage += `${<iai:variable vid="Zatwierdź"/>} ${<iai:variable vid="Regulamin"/>}!<br/>`;
// Błąd w formularzu // Błąd w formularzu
if(errorEl){ if(errorEl){
@@ -1837,6 +1832,7 @@ function checkNewsletter(logged, regular){
else if(document.querySelector(regular)) return document.querySelector(regular).checked ? 1 : 0; else if(document.querySelector(regular)) return document.querySelector(regular).checked ? 1 : 0;
else return 0; else return 0;
} }
// Funkcja wysyłająca zamówienie // Funkcja wysyłająca zamówienie
function sendOrder(data){ function sendOrder(data){
$.ajax({ $.ajax({