var price_with_options_ajax_call = function() { $.ajax({ type: 'POST', url: 'index.php?route=product/live_options/index&product_id=408', data: $('#quick-content input[type=\'text\'], #quick-content input[type=\'number\'], #quick-content input[type=\'hidden\'], #quick-content input[type=\'radio\']:checked, #quick-content input[type=\'checkbox\']:checked, #quick-content select, #quick-content textarea'), dataType: 'json', beforeSend: function() { // you can add smth useful here }, complete: function() { // you can add smth useful here }, success: function(json) { if (json.success) { if ($('#quick-content .price-tax-live').length > 0 && json.new_price.tax) { animation_on_change_price_with_options('#quick-content .price-tax-live', json.new_price.tax); } if ($('#quick-content .price-new-live').length > 0 && json.new_price.special) { animation_on_change_price_with_options('#quick-content .price-new-live', json.new_price.special); } if ($('#quick-content .price-old-live').length > 0 && json.new_price.price) { animation_on_change_price_with_options('#quick-content .price-old-live', json.new_price.price); } // points if ($('#quick-content .spend-points-live').length > 0 && json.new_price.points) { animation_on_change_price_with_options('#quick-content .spend-points-live', json.new_price.points); } // reward if ($('#quick-content .get-reward-live').length > 0 && json.new_price.reward) { animation_on_change_price_with_options('#quick-content .get-reward-live', 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 ($('#quick-content input[name=\'quantity\']').val() > 1) { price_with_options_ajax_call(); } if ( jQuery.isFunction(jQuery.fn.on) ) { $(document).on('change', '#quick-content input[type=\'hidden\'], #quick-content input[type=\'radio\']:checked, #quick-content input[type=\'checkbox\'], #quick-content select, #quick-content textarea', function () { price_with_options_ajax_call(); }); $(document).on('input', '#quick-content input[type=\'text\'], #quick-content input[type=\'number\'], #quick-content input[name=\'quantity\']', function () { price_with_options_ajax_call(); }); $(document).on('change', '#quick-content input[type=\'text\'], #quick-content input[type=\'number\'], #quick-content input[name=\'quantity\']', function () { price_with_options_ajax_call(); }); } else { $('#quick-content input[type=\'text\'], #quick-content input[type=\'number\'], #quick-content input[type=\'hidden\'], #quick-content input[type=\'radio\']:checked, #quick-content input[type=\'checkbox\'], #quick-content select, #quick-content textarea, #quick-content 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 Everthemes if( $('#quick-content .qty-plus').length || $('#quick-content .qty-minus').length ){ $(document).on('click', '#quick-content .qty-plus', function () { setTimeout(function() { price_with_options_ajax_call(); }, 100); }); $(document).on('click', '#quick-content .qty-minus', 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); }); }