İnfinity Dekoratif Kumaş
// ===== JOURNAL3 FİYAT SİSTEMİ HİJACK =====
function hijackJournal3PriceSystem() {
console.log('=== JOURNAL3 FİYAT SİSTEMİ HİJACK ===');
// Journal3'ün price AJAX'ını hijack et
var originalAjax = $.ajax;
$.ajax = function(options) {
// Journal3 price route'unu yakala
if (options.url && options.url.indexOf('journal3/price') !== -1) {
console.log('Journal3 price AJAX yakalandı! Fabric data:', window.fabricData);
// Eğer fabric hesaplama varsa custom response döndür
if (window.fabricData && window.fabricData.finalPrice) {
console.log('Custom fabric price response döndürülüyor:', window.fabricData.finalPrice);
var fakeResponse = {
success: true,
price: window.fabricData.finalPrice.toFixed(2) + '₺',
special: false,
tax: false,
discounts: [],
points: false,
in_stock: true,
stock: 'Stokta var',
quantity: 999,
fabric_hijacked: true
};
// Success callback'i hemen çağır
setTimeout(function() {
if (options.success) {
options.success(fakeResponse);
}
}, 10);
// Promise döndür
return {
done: function(callback) {
setTimeout(() => callback(fakeResponse), 10);
return this;
},
fail: function() { return this; },
always: function(callback) {
setTimeout(callback, 10);
return this;
}
};
}
}
// Normal AJAX'ları geçir
return originalAjax.call(this, options);
};
// Manual fiyat güncelleme fonksiyonu
function updateFabricPrice() {
if (window.fabricData && window.fabricData.finalPrice) {
var price = window.fabricData.finalPrice.toFixed(2) + '₺';
console.log('Manual fiyat güncelleniyor:', price);
// Tüm olası price selector'larını güncelle
$('.product-price').html(price);
$('.price .price-new').html(price).show();
$('.price .price-old').hide();
$('.product-price-group .price').html(price);
$('.product-price-group .price-new').html(price);
$('.product-price-group .price-old').hide();
$('#content .price').html(price);
$('.journal-price .price').html(price);
// Journal3 specific
$('.product-details .price').html(price);
$('.button-group-page .price').html(price);
}
}
// Option değişikliklerinde fiyat güncelle
$(document).on('input change', '#fabric-enhanced-input, #input-quantity', function() {
setTimeout(updateFabricPrice, 50);
});
return updateFabricPrice;
}
// Fabric hesaplama tamamlandığında hijack sistemi başlat
$(document).ready(function() {
// Journal3 yüklendikten sonra hijack başlat
setTimeout(function() {
if (typeof window.fabricData !== 'undefined' || $('#fabric-enhanced-input').length > 0) {
console.log('Fabric sistemi tespit edildi, Journal3 hijack başlatılıyor...');
var updatePrice = hijackJournal3PriceSystem();
// İlk hesaplama varsa fiyatı güncelle
if (window.fabricData) {
setTimeout(updatePrice, 200);
}
}
}, 1500); // Journal3'ün tamamen yüklenmesi için bekle
});
// Fabric hesaplayıcısının calculatePrice fonksiyonunu güncelle
// Mevcut calculatePrice fonksiyonunun sonuna şunu ekle:
/*
// calculatePrice fonksiyonunun sonunda:
setTimeout(function() {
if (window.fabricData && typeof hijackJournal3PriceSystem !== 'undefined') {
// Journal3'ün fiyat sistemini bypassla
var price = window.fabricData.finalPrice.toFixed(2) + '₺';
$('.product-price').html(price);
$('.price .price-new').html(price).show();
$('.price .price-old').hide();
}
}, 100);
*/