// Debug ve düzeltilmiş versiyon
(function () {
// Debug modunu aktif et
const DEBUG = true;
function log(message, data = '') {
if (DEBUG) {
console.log('[İkas Discount Script]', message, data);
}
}
let lastUrl = location.href;
// Sayfa kontrolü - daha geniş kontrol
if (location.href.includes("/cart") ||
location.href.includes("sepet") ||
location.href.includes("/checkout") ||
location.href.includes("/odeme")) {
log('Sepet/ödeme sayfasında, script durduruluyor');
return;
}
log('Script başlatıldı, URL:', location.href);
function parsePrice(text) {
if (!text) return NaN;
// Türkiye formatı için özel parsing
const cleaned = text.replace(/[^\d.,]/g, "");
log('Fiyat parsing:', text + ' → ' + cleaned);
if (cleaned.includes(",") && cleaned.includes(".")) {
// 1.234,56 formatı
if (cleaned.indexOf(",") > cleaned.indexOf(".")) {
const result = parseFloat(cleaned.replace(/\./g, "").replace(",", "."));
log('Format 1.234,56:', result);
return result;
} else {
// 1,234.56 formatı
const result = parseFloat(cleaned.replace(/,/g, ""));
log('Format 1,234.56:', result);
return result;
}
}
if (cleaned.includes(",") && !cleaned.includes(".")) {
// 1234,56 formatı
const result = parseFloat(cleaned.replace(",", "."));
log('Format 1234,56:', result);
return result;
}
// 1234.56 veya 1234 formatı
const result = parseFloat(cleaned.replace(/,/g, ""));
log('Format basit:', result);
return result;
}
function formatPrice(number) {
return number
.toFixed(2)
.replace(".", ",")
.replace(/\B(?=(\d{3})+(?!\d))/g, ".");
}
function findPriceElements() {
// Farklı seçicileri dene
const selectors = [
".sell-price",
".sell-price.flex",
".price",
".product-price",
"[data-testid*='price']",
"[class*='price']",
"[class*='Price']",
".sellPrice",
".current-price"
];
let allElements = [];
selectors.forEach(selector => {
try {
const elements = document.querySelectorAll(selector);
log(`Seçici "${selector}" buldu:`, elements.length + ' element');
allElements = [...allElements, ...Array.from(elements)];
} catch (e) {
log(`Seçici "${selector}" hatası:`, e.message);
}
});
// Tekrar eden elementleri kaldır
const uniqueElements = [...new Set(allElements)];
log('Toplam benzersiz fiyat elementi:', uniqueElements.length);
return uniqueElements;
}
function applyDiscounts() {
log('Indirim uygulama başladı');
const discountRate = 0.2; // %20 indirim
const discountLabel = "Sepette %20 indirim";
const priceElements = findPriceElements();
if (priceElements.length === 0) {
log('Hiç fiyat elementi bulunamadı!');
// Sayfadaki tüm elementleri kontrol et
const allElements = document.querySelectorAll('*');
let priceCount = 0;
allElements.forEach(el => {
if (el.textContent && /₺|TL|\d+[.,]\d+/.test(el.textContent)) {
priceCount++;
}
});
log('Sayfada fiyat içeren element sayısı:', priceCount);
return;
}
let processedCount = 0;
priceElements.forEach(function (priceElement, index) {
log(`Element ${index + 1} işleniyor:`, priceElement.className);
// Sepet ve drawer kontrolü - daha detaylı
const excludeSelectors = [
'[class*="overlay-category-drawer-main"]',
'[class*="drawer"]',
'[class*="right-0"]',
'[class*="cart"]',
'[class*="Cart"]',
'.mini-cart',
'[data-testid*="cart"]',
'aside',
'.sidebar'
];
let shouldExclude = false;
excludeSelectors.forEach(excludeSelector => {
if (priceElement.closest(excludeSelector)) {
shouldExclude = true;
log(`Element excluded by: ${excludeSelector}`);
}
});
if (shouldExclude) return;
// Zaten işlenmiş mi kontrol et
if (priceElement.dataset.discountApplied === "true") {
log('Element zaten işlenmiş');
return;
}
const priceText = priceElement.textContent?.trim();
log('Fiyat metni:', priceText);
const originalPrice = parsePrice(priceText);
if (!isNaN(originalPrice) && originalPrice > 0) {
const discountedPrice = originalPrice * (1 - discountRate);
log(`Indirim hesaplandı: ${originalPrice} → ${discountedPrice}`);
// Orijinal HTML'i sakla
const originalHTML = priceElement.innerHTML;
priceElement.dataset.originalHTML = originalHTML;
priceElement.innerHTML = `
₺ ${formatPrice(originalPrice)}
₺ ${formatPrice(discountedPrice)}
${discountLabel}
`;
priceElement.dataset.discountApplied = "true";
processedCount++;
log('Indirim uygulandı!');
} else {
log('Geçersiz fiyat:', originalPrice);
}
});
log(`Toplam ${processedCount} elemente indirim uygulandı`);
}
// Daha sağlam başlatma
function initialize() {
log('Initialize çağrıldı, readyState:', document.readyState);
if (document.readyState === 'loading') {
document.addEventListener("DOMContentLoaded", () => {
log('DOMContentLoaded event');
setTimeout(applyDiscounts, 3000);
});
} else {
log('DOM hazır, hemen başlatılıyor');
setTimeout(applyDiscounts, 500);
}
}
// Window load event
window.addEventListener("load", () => {
log('Window load event');
setTimeout(applyDiscounts, 1500);
});
// URL değişikliklerini izle
let urlCheckInterval = setInterval(() => {
if (location.href !== lastUrl) {
log('URL değişti:', lastUrl + ' → ' + location.href);
lastUrl = location.href;
if (
!location.href.includes("/cart") &&
!location.href.includes("sepet") &&
!location.href.includes("/checkout") &&
!location.href.includes("/odeme")
) {
setTimeout(applyDiscounts, 800);
}
}
}, 1000);
// DOM değişikliklerini izle - daha performanslı
let observerTimeout;
const observer = new MutationObserver((mutations) => {
if (
!location.href.includes("/cart") &&
!location.href.includes("sepet") &&
!location.href.includes("/checkout") &&
!location.href.includes("/odeme")
) {
clearTimeout(observerTimeout);
observerTimeout = setTimeout(() => {
log('DOM değişikliği algılandı');
applyDiscounts();
}, 500);
}
});
// Observer'ı başlat
if (document.body) {
observer.observe(document.body, {
childList: true,
subtree: true,
});
} else {
// Body henüz yüklenmemişse bekle
setTimeout(() => {
if (document.body) {
observer.observe(document.body, {
childList: true,
subtree: true,
});
}
}, 100);
}
// Horizontal scroll için (detay slider)
let yatayScrollTimeout;
function setupScrollListeners() {
const scrollContainers = [
'.detaySliderContainer',
'[class*="slider"]',
'[class*="carousel"]',
'[class*="scroll"]'
];
scrollContainers.forEach(selector => {
const containers = document.querySelectorAll(selector);
containers.forEach(container => {
container.addEventListener("scroll", () => {
clearTimeout(yatayScrollTimeout);
yatayScrollTimeout = setTimeout(() => {
log('Scroll event tetiklendi');
applyDiscounts();
}, 300);
});
});
});
}
// Script başlatma
initialize();
// Scroll listener'ları kurma
setTimeout(setupScrollListeners, 2000);
// Debug için global erişim
window.ikasDiscountDebug = {
applyDiscounts,
findPriceElements,
parsePrice,
formatPrice,
log,
lastUrl,
reinitialize: initialize
};
log('Script yüklendi, debug console açık');
log('Manual test için: ikasDiscountDebug.applyDiscounts()');
})();// Debug ve düzeltilmiş versiyon
(function () {
// Debug modunu aktif et
const DEBUG = true;
function log(message, data = '') {
if (DEBUG) {
console.log('[İkas Discount Script]', message, data);
}
}
let lastUrl = location.href;
// Sayfa kontrolü - daha geniş kontrol
if (location.href.includes("/cart") ||
location.href.includes("sepet") ||
location.href.includes("/checkout") ||
location.href.includes("/odeme")) {
log('Sepet/ödeme sayfasında, script durduruluyor');
return;
}
log('Script başlatıldı, URL:', location.href);
function parsePrice(text) {
if (!text) return NaN;
// Türkiye formatı için özel parsing
const cleaned = text.replace(/[^\d.,]/g, "");
log('Fiyat parsing:', text + ' → ' + cleaned);
if (cleaned.includes(",") && cleaned.includes(".")) {
// 1.234,56 formatı
if (cleaned.indexOf(",") > cleaned.indexOf(".")) {
const result = parseFloat(cleaned.replace(/\./g, "").replace(",", "."));
log('Format 1.234,56:', result);
return result;
} else {
// 1,234.56 formatı
const result = parseFloat(cleaned.replace(/,/g, ""));
log('Format 1,234.56:', result);
return result;
}
}
if (cleaned.includes(",") && !cleaned.includes(".")) {
// 1234,56 formatı
const result = parseFloat(cleaned.replace(",", "."));
log('Format 1234,56:', result);
return result;
}
// 1234.56 veya 1234 formatı
const result = parseFloat(cleaned.replace(/,/g, ""));
log('Format basit:', result);
return result;
}
function formatPrice(number) {
return number
.toFixed(2)
.replace(".", ",")
.replace(/\B(?=(\d{3})+(?!\d))/g, ".");
}
function findPriceElements() {
// Farklı seçicileri dene
const selectors = [
".sell-price",
".sell-price.flex",
".price",
".product-price",
"[data-testid*='price']",
"[class*='price']",
"[class*='Price']",
".sellPrice",
".current-price"
];
let allElements = [];
selectors.forEach(selector => {
try {
const elements = document.querySelectorAll(selector);
log(`Seçici "${selector}" buldu:`, elements.length + ' element');
allElements = [...allElements, ...Array.from(elements)];
} catch (e) {
log(`Seçici "${selector}" hatası:`, e.message);
}
});
// Tekrar eden elementleri kaldır
const uniqueElements = [...new Set(allElements)];
log('Toplam benzersiz fiyat elementi:', uniqueElements.length);
return uniqueElements;
}
function applyDiscounts() {
log('Indirim uygulama başladı');
const discountRate = 0.2; // %20 indirim
const discountLabel = "Sepette %20 indirim";
const priceElements = findPriceElements();
if (priceElements.length === 0) {
log('Hiç fiyat elementi bulunamadı!');
// Sayfadaki tüm elementleri kontrol et
const allElements = document.querySelectorAll('*');
let priceCount = 0;
allElements.forEach(el => {
if (el.textContent && /₺|TL|\d+[.,]\d+/.test(el.textContent)) {
priceCount++;
}
});
log('Sayfada fiyat içeren element sayısı:', priceCount);
return;
}
let processedCount = 0;
priceElements.forEach(function (priceElement, index) {
log(`Element ${index + 1} işleniyor:`, priceElement.className);
// Sepet ve drawer kontrolü - daha detaylı
const excludeSelectors = [
'[class*="overlay-category-drawer-main"]',
'[class*="drawer"]',
'[class*="right-0"]',
'[class*="cart"]',
'[class*="Cart"]',
'.mini-cart',
'[data-testid*="cart"]',
'aside',
'.sidebar'
];
let shouldExclude = false;
excludeSelectors.forEach(excludeSelector => {
if (priceElement.closest(excludeSelector)) {
shouldExclude = true;
log(`Element excluded by: ${excludeSelector}`);
}
});
if (shouldExclude) return;
// Zaten işlenmiş mi kontrol et
if (priceElement.dataset.discountApplied === "true") {
log('Element zaten işlenmiş');
return;
}
const priceText = priceElement.textContent?.trim();
log('Fiyat metni:', priceText);
const originalPrice = parsePrice(priceText);
if (!isNaN(originalPrice) && originalPrice > 0) {
const discountedPrice = originalPrice * (1 - discountRate);
log(`Indirim hesaplandı: ${originalPrice} → ${discountedPrice}`);
// Orijinal HTML'i sakla
const originalHTML = priceElement.innerHTML;
priceElement.dataset.originalHTML = originalHTML;
priceElement.innerHTML = `
₺ ${formatPrice(originalPrice)}
₺ ${formatPrice(discountedPrice)}
${discountLabel}
`;
priceElement.dataset.discountApplied = "true";
processedCount++;
log('Indirim uygulandı!');
} else {
log('Geçersiz fiyat:', originalPrice);
}
});
log(`Toplam ${processedCount} elemente indirim uygulandı`);
}
// Daha sağlam başlatma
function initialize() {
log('Initialize çağrıldı, readyState:', document.readyState);
if (document.readyState === 'loading') {
document.addEventListener("DOMContentLoaded", () => {
log('DOMContentLoaded event');
setTimeout(applyDiscounts, 3000);
});
} else {
log('DOM hazır, hemen başlatılıyor');
setTimeout(applyDiscounts, 500);
}
}
// Window load event
window.addEventListener("load", () => {
log('Window load event');
setTimeout(applyDiscounts, 1500);
});
// URL değişikliklerini izle
let urlCheckInterval = setInterval(() => {
if (location.href !== lastUrl) {
log('URL değişti:', lastUrl + ' → ' + location.href);
lastUrl = location.href;
if (
!location.href.includes("/cart") &&
!location.href.includes("sepet") &&
!location.href.includes("/checkout") &&
!location.href.includes("/odeme")
) {
setTimeout(applyDiscounts, 800);
}
}
}, 1000);
// DOM değişikliklerini izle - daha performanslı
let observerTimeout;
const observer = new MutationObserver((mutations) => {
if (
!location.href.includes("/cart") &&
!location.href.includes("sepet") &&
!location.href.includes("/checkout") &&
!location.href.includes("/odeme")
) {
clearTimeout(observerTimeout);
observerTimeout = setTimeout(() => {
log('DOM değişikliği algılandı');
applyDiscounts();
}, 500);
}
});
// Observer'ı başlat
if (document.body) {
observer.observe(document.body, {
childList: true,
subtree: true,
});
} else {
// Body henüz yüklenmemişse bekle
setTimeout(() => {
if (document.body) {
observer.observe(document.body, {
childList: true,
subtree: true,
});
}
}, 100);
}
// Horizontal scroll için (detay slider)
let yatayScrollTimeout;
function setupScrollListeners() {
const scrollContainers = [
'.detaySliderContainer',
'[class*="slider"]',
'[class*="carousel"]',
'[class*="scroll"]'
];
scrollContainers.forEach(selector => {
const containers = document.querySelectorAll(selector);
containers.forEach(container => {
container.addEventListener("scroll", () => {
clearTimeout(yatayScrollTimeout);
yatayScrollTimeout = setTimeout(() => {
log('Scroll event tetiklendi');
applyDiscounts();
}, 300);
});
});
});
}
// Script başlatma
initialize();
// Scroll listener'ları kurma
setTimeout(setupScrollListeners, 2000);
// Debug için global erişim
window.ikasDiscountDebug = {
applyDiscounts,
findPriceElements,
parsePrice,
formatPrice,
log,
lastUrl,
reinitialize: initialize
};
log('Script yüklendi, debug console açık');
log('Manual test için: ikasDiscountDebug.applyDiscounts()');
})();
Ceket Crop Mavi Blazer Kadın Ceket SWASS Crop Mavi Blazer Kadın Ceket
Ürün tesliminden itibaren
14 gün içinde iade veya değişim talebinde bulunabilirsiniz.
- Ürün kullanılmamış, etiketi çıkarılmamış ve orijinal ambalajında olmalıdır.
- Değişim işlemleri stok durumu dikkate alınarak gerçekleştirilir.
📧 İade talepleri için:
[email protected]
📞 Telefon:
+90 533 302 71 02
2500 TL üzeri ücretsiz kargo 14 gün içinde iade değişim Ürün Özellikler:Kumaşı orta kalınlıkta, içi astarlıdır, Numune Beden: 36/S/1 Modelin Ölçüleri: Boy: 178, Gögüs: 84, Bel: 60, Basen: 90 Yıkama Talimatı ürünün iç kısmında yer almaktadır.