foreach ile aldığım ürünlerin fiyatını seçeneklere göre anlık değiştirmeye çalışıyorum. tek üründe sorun yok, kategori kısmında ise ürün id sorunsuz alıyor, değişen fiyatı ilgili üründe değil, son sıradaki ürüne göre yapmak istiyor. son ürünün id tuttuğu için sorun yok, diğer ürünlerde ise id farklı olduğu için herhangi bir güncelleneme yapmıyor.
gözden kaçırdığım birşey var ama ne olduğu göremiyorum... lütfen yardım arkadaşlar.
var price_with_options_ajax_call = function() {
jQuery.ajax({
type: 'POST',
url: 'index.php?route=product/live_options/index&product_id=$product_id',
data: $('{$this->options_container} input[type=\'text\'], {$this->options_container} input[type=\'number\'], {$this->options_container} input[type=\'hidden\'], {$this->options_container} input[type=\'radio\']:checked, {$this->options_container} input[type=\'checkbox\']:checked, {$this->options_container} select, {$this->options_container} textarea'),
dataType: 'json',
beforeSend: function() {
},
complete: function() {
},
success: function(json) {
if (json.success) {
if ($('{$this->options_container} {$this->tax_price_container}$product_id').length > 0 && json.new_price.tax) {
animation_on_change_price_with_options('{$this->options_container} {$this->tax_price_container}$product_id', json.new_price.tax);
}
if ($('{$this->options_container} {$this->special_price_container}$product_id').length > 0 && json.new_price.special) {
animation_on_change_price_with_options('{$this->options_container} {$this->special_price_container}$product_id', json.new_price.special);
}
if ($('{$this->options_container} {$this->price_container}$product_id').length > 0 && json.new_price.price) {
animation_on_change_price_with_options('{$this->options_container} {$this->price_container}$product_id', json.new_price.price);
}
// points
if ($('{$this->options_container} {$this->points_container}$product_id').length > 0 && json.new_price.points) {
animation_on_change_price_with_options('{$this->options_container} {$this->points_container}$product_id', json.new_price.points);
}
// reward
if ($('{$this->options_container} {$this->reward_container}$product_id').length > 0 && json.new_price.reward) {
animation_on_change_price_with_options('{$this->options_container} {$this->reward_container}$product_id', json.new_price.reward);
}
}
},
error: function(error) {
console.log('error: '+error);
}
});
}
var animation_on_change_price_with_options = function(selector_class_or_id, new_html_content) {
$(selector_class_or_id).fadeOut(150, function() {
$(this).html(new_html_content).fadeIn(50);
});
}
if ( jQuery.isFunction(jQuery.fn.on) )
{
$(document).on('change', '{$this->options_container} input[type=\'text\'], {$this->options_container} input[type=\'number\'], {$this->options_container} input[type=\'hidden\'], {$this->options_container} input[type=\'radio\']:checked, {$this->options_container} input[type=\'checkbox\'], {$this->options_container} select, {$this->options_container} textarea, {$this->options_container} input[name=\'quantity\']', function () {
price_with_options_ajax_call();
});
}
else
{
$('{$this->options_container} input[type=\'text\'], {$this->options_container} input[type=\'number\'], {$this->options_container} input[type=\'hidden\'], {$this->options_container} input[type=\'radio\']:checked, {$this->options_container} input[type=\'checkbox\'], {$this->options_container} select, {$this->options_container} textarea, {$this->options_container} input[name=\'quantity\']').live('change', function() {
price_with_options_ajax_call();
});
}
// Support spinner_quantity
if( $('.number-spinner button').length ){
$(document).on('click', '.number-spinner button', function () {
setTimeout(function() {
price_with_options_ajax_call();
}, 100);
});
}
// Support bt_claudine
if( $('.increase').length || $('.decrease').length ){
$(document).on('click', '.increase', function () {
setTimeout(function() {
price_with_options_ajax_call();
}, 100);
});
$(document).on('click', '.decrease', function () {
setTimeout(function() {
price_with_options_ajax_call();
}, 100);
});
}
// Support Pav theme
if( $('.quantity-adder .add-action').length ){
$(".quantity-adder .add-action").bind( "mouseup touchend", function(e){
setTimeout(function() {
price_with_options_ajax_call();
}, 100);
});
}
// Support vitalia
if( $('#q_up').length || $('#q_down').length ){
$('#q_up,#q_down').click(function(){
setTimeout(function() {
price_with_options_ajax_call();
}, 100);
});
}