$arResult = array();
$productID = $arRequest['id'];
$quantity = (int) $arRequest['quantity'] > 0 ? (int) $arRequest['quantity'] : 1;
$res = Add2BasketByProductID($productID, $quantity, array(), array());
if($res) {
$arResult['success'] = true;
}
$('body').on('click', '.js-add-tocart', function() {
var thisUrl = '/ajax/basket.php';
var productID = $(this).attr('data-product-id');
var quantity = $('.product__count-input').val();
var btn = $(this);
$.ajax({
type: 'post',
url: thisUrl,
data: {ajax_basket:'Y', id:productID, quantity:quantity, action:'add'},
dataType: 'html',
success: function(result) {
$.fancybox.open(result, {touch: false});
},
complete: function() {
js_top_basket.refreshCart({});
},
error: function() {
console.log('Net Error');
},
});
return false;
});
refreshCart({})
$('body').on('click', '.js__basket-item-del', function() {
var id = $(this).attr('data-id');
var url = '/ajax/basket_del.php';
if(confirm('Вы подтверждаете операцию?')) {
$.ajax( {
type: 'post',
url: url,
data: {'ajax_basket':'Y', 'id':id, 'action':'delete'},
dataType: 'json',
success: function(result) {
if(result.count > 0) {
js_top_basket.refreshCart({});
submitForm();
} else {
window.location.reload();
}
},
complete: function() {
},
error: function() {
console.log('Net Error');
},
});
}
return false;
});
refreshCart({})