Usunięcie zbędnych plików .DS_Store oraz dodanie skryptu do automatycznego wyboru opcji płatności

This commit is contained in:
2025-10-15 12:57:44 +02:00
parent 9de1ac9d1f
commit 95b6ff255c
31 changed files with 251 additions and 8 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 371 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 359 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 381 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 242 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 244 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 505 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 69 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 190 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 47 KiB

View File

@@ -1053,4 +1053,96 @@ $(document).ready(function () {
localStorage.removeItem('selectedSize')
}
})
});
(() => {
// Ustaw na true, jeśli Twój motyw/moduł wymaga faktycznego submitu "Wybierz"
const FORCE_SUBMIT_TO_SELECT = false;
const isVisible = (el) => {
if (!el) return false;
const s = getComputedStyle(el);
if (s.display === 'none' || s.visibility === 'hidden') return false;
const r = el.getBoundingClientRect();
return !!(r.width || r.height || el.getClientRects().length);
};
const getContainer = () =>
document.querySelector('#checkout-payment-step .payment-options, .payment-options');
const getRows = () => {
const c = getContainer();
if (!c) return [];
return [...c.querySelectorAll('.payment-option')].filter(isVisible);
};
const fireAll = (el) => {
// Maksymalnie „głośno”: click + input + change (bubbles)
el.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true, view: window }));
el.dispatchEvent(new Event('input', { bubbles: true }));
el.dispatchEvent(new Event('change', { bubbles: true }));
};
const pickRow = (row) => {
if (!row) return false;
const radio = row.querySelector('input[name="payment-option"][type="radio"]');
if (!radio) return false;
// 1) „Fizyczny” klik w radio
radio.focus();
radio.click(); // często wystarcza
radio.checked = true; // twardo ustaw
fireAll(radio); // wyślij eventy
// 2) Dopnij .active, jeśli motyw nie zrobił tego sam
row.classList.add('active');
// 3) (opcjonalnie) wyślij ukryty "Wybierz"
if (FORCE_SUBMIT_TO_SELECT) {
const btn = row.querySelector('button[name="select_payment_option"]');
if (btn && isVisible(btn) || btn) {
btn.click(); // UWAGA: może przeładować sekcję / stronę wg motywu
}
}
return true;
};
const run = () => {
const rows = getRows();
if (!rows.length) return;
// Jeśli jest tylko jedna wybierz ją
if (rows.length === 1) {
pickRow(rows[0]);
return;
}
// Jeśli jakaś ma już .active dopilnuj, że radio naprawdę zaznaczone
const active = rows.find(r => r.classList.contains('active')) || null;
if (active) {
const radio = active.querySelector('input[name="payment-option"][type="radio"]');
if (radio && !radio.checked) pickRow(active);
}
};
// start + kilka retry (czasem bindingi dochodzą z opóźnieniem)
run();
setTimeout(run, 80);
setTimeout(run, 200);
setTimeout(run, 450);
// Obserwator przebudów sekcji płatności
const target = document.querySelector('#checkout-payment-step') || document.body;
let t;
const obs = new MutationObserver((muts) => {
if (muts.some(m =>
m.target?.closest?.('#checkout-payment-step') ||
[...m.addedNodes].some(n => n.nodeType === 1 && (n.id === 'checkout-payment-step' || n.querySelector?.('.payment-options')))
)) {
clearTimeout(t);
t = setTimeout(run, 60);
}
});
obs.observe(target, { childList: true, subtree: true, attributes: true, attributeFilter: ['class','style'] });
})();