In general, I’m running data through ajax to a php page, and there I record them in a session after reloading the page and there’s nothing on the bitrix in the output session array. Here is the code to send data:
$('.btn-price').click(function() { $.ajax({ url: 'addtobasket.php', type: "POST", dataType: "JSON", data: { 'id': <?=$arResult["ID"]?>, 'name': '<?=$arResult["NAME"]?>', 'img': '<?=$arResult["DETAIL_PICTURE"]["SRC"]?>', 'qty': $('input[name="qty"]').val(), 'price': $('input[name="price"]').val() }, success: function (data) { if(data.status == "OK") { alert("Товар добавлен."); window.location.reload(); } }, error: function(xhr, status, error) { alert(xhr.responseText + '|\n' + status + '|\n' +error); } }); }); Here is the code of the work in the file:
if(isset($_SESSION['card'][$_REQUEST["id"]])){ //если в массиве уже есть добавляемый товар $_SESSION['card'][$_REQUEST["id"]]['qty'] += $_REQUEST["qty"]; //total_quantity(); echo json_encode(['status' => 'OK']); } else { //если в корзине нет такого товара $_SESSION['card'][$_REQUEST["id"]]['name'] = $_REQUEST["name"]; if ($_REQUEST["img"] != "") { $_SESSION['card'][$_REQUEST["id"]]['img'] = $_REQUEST["img"]; } $_SESSION['card'][$_REQUEST["id"]]['qty'] = $_REQUEST["qty"]; $_SESSION['card'][$_REQUEST["id"]]['price'] = $_REQUEST["price"]; //total_quantity(); echo json_encode(['status' => 'OK']); } I have already broken my head what the problem is, tell me maybe it’s not at all in the code.