<?require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php");
$count = $_POST['count'];
$id = $_POST['id'];
$add = $_POST['add'];
$mess = '';
CModule::IncludeModule('iblock');
CModule::IncludeModule('catalog');
CModule::IncludeModule('currency');
CModule::IncludeModule("sale");
?>
<?
if (CModule::IncludeModule("catalog") && CModule::IncludeModule("sale")) {
// ADD TO CART
if ($_POST['id']) {
$propArr = array();
$count = ($_POST['count']) ? $_POST['count'] : 1;
Add2BasketByProductID(
$id,
$count,
$propArr
);
}
// UPDATE QUANTITY
if ($_POST['update'] == 'Y' && $_POST['id'] && $_POST['count']) {
$arFields = array(
"QUANTITY" => $_POST['count'],
);
CSaleBasket::Update($_POST['id'], $arFields);
}
// DELETE PRODUCT
if ($_POST['delete'] == 'Y' && $_POST['id']) {
CSaleBasket::Delete($_POST['id']);
}
}
else { echo "Не подключены модули"; }
AddMessage2Log("<br/><br/><pre>".print_r($_POST,true)."</pre><br/><br/>", "test");
echo $mess;
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_after.php");
?>
$count = $_POST['count'];
$id = $_POST['id'];
$add = $_POST['add'];
$mess = '';
AddMessage2Log("<br/><br/><pre>".print_r($_POST,true)."</pre><br/><br/>", "test");
<form id="basket" action="/bitrix/templates/dveri/ajax/basket.php" method="POST" enctype="multipart/form-data">
<input type="hidden" value="<?=$arItem["ID"];?>" name="id" name="id">
<input type="hidden" value="Y" name="add" name="add">
<span class="plus">+</span>
<span class="minus">-</span>
<input type="text" name="count" value="<?=$arItem["BASKET_QUANTITY"];?>" class="count" id="count">
<button type="button" id="send" name="button" style="cursor: pointer;">В корзину</button>
</form>
$(document).ready(function(){
//минус количество к input#count
$('.minus').click(function () {
var $input = $(this).parent().find('#count');
var count = parseInt($input.val()) - 1;
count = count < 1 ? 1 : count;
$input.val(count);
$input.change();
return false;
});
//плюч количество к input#count
$('.plus').click(function () {
var $input = $(this).parent().find('#count');
$input.val(parseInt($input.val()) + 1);
$input.change();
return false;
});
//отправка по ajax
$("#send").on("click", function () {
var count = $("#count").val().trim();
var id = $("#id").val().trim();
var add = $("#add").val().trim();
$.ajax({
url: '/bitrix/templates/dveri/ajax/basket.php', //?uploadfiles
type: 'POST',
cache: false,
data: {'count': count, 'id': id, 'add': add},
//processData: false,
//contentType: false,
/*beforeSend: function () {
$("#send").prop("disabled", true);
},*/
success: function (data) {
if (!data) {
alert ('Были допущены ошибки, количество не отправлено');
}
else {
$("#basket").trigger("reset");
alert ('количество отправлено');
}
$("#send").prop("disabled", false);
},
});
});
});
$count = $_POST['count'];
$id = $_POST['id'];
$add = $_POST['add'];
$mess = '';