Написать отзыв
$(‘select[name=’recurring_id’], input[name=”quantity”]’).change(function(){
$.ajax({
url: ‘index.php?route=product/product/getRecurringDescription’,
type: ‘post’,
data: $(‘input[name=’product_id’], input[name=’quantity’], select[name=’recurring_id’]’),
dataType: ‘json’,
beforeSend: function() {
$(‘#recurring-description’).html(”);
},
success: function(json) {
$(‘.alert, .text-danger’).remove();
if (json[‘success’]) {
$(‘#recurring-description’).html(json[‘success’]);
}
}
});
});
//ppo js
var all_inputs = $(‘.row.product-options-row input’);
var ppo_sum = 0;
var ppo_quantity = 0;
var ppo_ids = [];
var remove_all_button_toggle = function(){
if(all_inputs.prop(‘checked’)||all_inputs.is(‘:checked’)) {
$(‘.rmv-all-options’).show();
} else {
$(‘.rmv-all-options’).hide();
}
}
var remove_all_checks = function(){
$(‘.row.product-options-row input’).removeAttr(‘checked’).change();
}
var sum_of_all_checked = function(){
$(all_inputs).each(function() {
if (this.checked) {
ppo_ids.push($(this).data(‘itemPrice’));
ppo_sum += parseInt($(this).data(‘itemPrice’), 10);
}
});
$( “.ppo-main-heading span.label-success” ).text( ppo_sum > 0 ? “Выбрано ” + ppo_ids.length + ” шт., общей стоимостью ” + ppo_sum + “р.” : “” );
}
$(‘.rmv-all-options’).on(‘click’, function(){
remove_all_checks();
remove_all_button_toggle();
});
$(all_inputs).on(“change”, function(){
remove_all_button_toggle();
//remove_all_checks();
ppo_sum = 0;
ppo_ids = [];
sum_of_all_checked();
});
$(‘#button-cart’).on(‘click’, function() {
$.ajax({
url: ‘index.php?route=checkout/cart/add’,
type: ‘post’,
data: $(‘#product input[type=’text’], #product input[type=’hidden’], #product input[type=’radio’]:checked, #product input[type=’checkbox’]:checked, #product select, #ppo-panel input:checked, #product textarea’),
dataType: ‘json’,
beforeSend: function() {
$(‘#button-cart’).button(‘loading’);
},
complete: function() {
$(‘#button-cart’).button(‘reset’);
},
success: function(json) {
$(‘.alert, .text-danger’).remove();
$(‘.form-group’).removeClass(‘has-error’);
if (json[‘error’]) {
if (json[‘error’][‘option’]) {
for (i in json[‘error’][‘option’]) {
var element = $(‘#input-option’ + i.replace(‘_’, ‘-‘));
if (element.parent().hasClass(‘input-group’)) {
element.parent().after(‘
‘ + json[‘error’][‘option’][i] + ”);
} else {
element.after(‘
‘ + json[‘error’][‘option’][i] + ”);
}
}
}
if (json[‘error’][‘recurring’]) {
$(‘select[name=’recurring_id’]’).after(‘
‘ + json[‘error’][‘recurring’] + ”);
}
// Highlight any found errors
$(‘.text-danger’).parent().addClass(‘has-error’);
}
if (json[‘success’]) {
$(‘.breadcrumb’).after(‘
‘ + json[‘success’] + ‘ |