setTimeout(function () {
const countrySelect = document.querySelector("select[name='billing[country_id]']");
let observerActive = false;function applyCODRules() {
const codMethodDiv = document.querySelector("div[data-value='phoenix_cashondelivery']");
const cardMethodDiv = document.querySelector("div[data-value='emppayeb']");
const paymentSelect = document.querySelector("select[name='payment[method]']");
const selectedPaymentDiv = document.querySelector(".iwd_opc_select_option.selected");const originalText = "??t??ata???";
const disabledText = originalText + " (?e? ?p?st????eta? ??a ??p??)";if (countrySelect.value === 'CY') {
if (codMethodDiv.innerText !== disabledText) {
codMethodDiv.style.pointerEvents = "none";
codMethodDiv.style.opacity = "0.5";
codMethodDiv.style.textDecoration = "line-through";
codMethodDiv.innerText = disabledText;
}if (paymentSelect) {
paymentSelect.value = "emppayeb";
paymentSelect.dispatchEvent(new Event('change', { bubbles: true }));
}
else if (selectedPaymentDiv !== cardMethodDiv) {
if (selectedPaymentDiv) {
selectedPaymentDiv.classList.remove("selected");
}
cardMethodDiv.classList.add("selected");const event = new MouseEvent("click", {
view: window,
bubbles: true,
cancelable: true
});
cardMethodDiv.dispatchEvent(event);
}
} else {
if (codMethodDiv.innerText !== originalText) {
codMethodDiv.style.pointerEvents = "auto";
codMethodDiv.style.opacity = "1";
codMethodDiv.style.textDecoration = "none";
codMethodDiv.innerText = originalText;
}
}
}if (countrySelect) {
applyCODRules();
countrySelect.addEventListener('change', () => {
applyCODRules();
});
}const targetNode = document.querySelector("#checkout-payment-method-load") || document.body;
const observer = new MutationObserver(function () {
if (observerActive) return;
observerActive = true;
setTimeout(() => {
requestAnimationFrame(() => {
applyCODRules();
observerActive = false;
});
}, 50);
});observer.observe(targetNode, { childList: true, subtree: true });
document.addEventListener('click', function (e) {
const tab = e.target.closest("#opc-payment, .step-title[data-step='payment']");
if (tab) {
setTimeout(applyCODRules, 100);
}
});}, 2000);