<?require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php");
use Bitrix\Main\Loader;
Loader::includeModule('sale');
Loader::includeModule('catalog');
$count = $_POST['count'];
$id = $_POST['id'];
$add = $_POST['add'];
$mess = '';
$PRICE_ID = '1';
$SITEE_ID = 's5';
$RUB = 'RUB';
$PRICE = $_POST['price'];
//Комплекты
$PRICE_korob = $_POST['price_korob'];
$PRICE_plintus = $_POST['price_plintus'];
$PRICE_nal = $_POST['price_nal'];
$id_korob = $_POST['id_korob'];
$id_plintus = $_POST['id_plintus'];
$id_nal = $_POST['id_nal'];
// Получаем корзину пользователя
$basket = \Bitrix\Sale\Basket::LoadItemsForFUser(
\Bitrix\Sale\Fuser::getId(),
$SITEE_ID
);
//товар
$product = array('PRODUCT_ID' => $id, 'QUANTITY' => $count, 'CURRENCY' => $RUB, 'BASE_PRICE' => $PRICE,);
$result = \Bitrix\Catalog\Product\Basket::addProductToBasket($basket, $product, array('SITE_ID' => $SITEE_ID));
//короб
$product_korob = array('PRODUCT_ID' => $id_korob, 'QUANTITY' => $count, 'CURRENCY' => $RUB, 'BASE_PRICE' => $PRICE_korob,);
$result_korob = \Bitrix\Catalog\Product\Basket::addProductToBasket($basket, $product_korob, array('SITE_ID' => $SITEE_ID));
//плинтус
$product_plintus = array('PRODUCT_ID' => $id_plintus, 'QUANTITY' => $count, 'CURRENCY' => $RUB, 'BASE_PRICE' => $PRICE_plintus,);
$result_plintus = \Bitrix\Catalog\Product\Basket::addProductToBasket($basket, $product_plintus, array('SITE_ID' => $SITEE_ID));
//наличник
$product_nal = array('PRODUCT_ID' => $id_nal, 'QUANTITY' => $count, 'CURRENCY' => $RUB, 'BASE_PRICE' => $PRICE_nal,);
$result_nal = \Bitrix\Catalog\Product\Basket::addProductToBasket($basket, $product_nal, array('SITE_ID' => $SITEE_ID));
if (!$result->isSuccess()) {
var_dump($result->getErrorMessage());
}
$basket->save();
//if ($result==true) {
?>
<?//}
//AddMessage2Log("<br/><br/><pre>".print_r($count,true)."</pre><br/><br/>", "test");
//AddMessage2Log("<br/><br/><pre>".print_r($id,true)."</pre><br/><br/>", "test");
//AddMessage2Log("<br/><br/><pre>".print_r($result,true)."</pre><br/><br/>", "test");
echo $mess;
/**/
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_after.php");
?>
$(document).ready(function(){
//отправка по ajax
$("#send").on("click", function () {
var count = $("#count").val();
var id = $("#id").val();
var add = $("#add").val();
var price = $("#price").val();
var id_korob = $("#id_korob").val();
var price_korob = $("#price_korob").val();
var id_plintus = $("#id_plintus").val();
var price_plintus = $("#price_plintus").val();
var id_nal = $("#id_nal").val();
var price_nal = $("#price_nal").val();
$.ajax({
url: '/bitrix/templates/dveri/ajax/basket.php', //?uploadfiles
type: 'POST',
cache: false,
data: {'count': count, 'id': id, 'add': add, 'price': price, 'id_nal': id_nal, 'price_nal': price_nal, 'id_korob': id_korob, 'price_korob': price_korob, 'id_plintus': id_plintus, 'price_plintus': price_plintus},
//processData: false,
//contentType: false,
/*beforeSend: function () {
$("#send").prop("disabled", true);
},*/
success: function (data) {
$('.popup-fade').fadeIn();
return false;
/*if (!data) {
alert ('Были допущены ошибки, количество не отправлено');
}
else {
$("#basket").trigger("reset");
alert ('количество отправлено');
}
console.dir(data);*/
//$("#send").prop("disabled", false);
},
error: function (jqXHR, exception) {
if (jqXHR.status === 0) {
alert('Not connect. Verify Network.');
} else if (jqXHR.status == 404) {
alert('Requested page not found (404).');
} else if (jqXHR.status == 500) {
alert('Internal Server Error (500).');
} else if (exception === 'parsererror') {
alert('Requested JSON parse failed.');
} else if (exception === 'timeout') {
alert('Time out error.');
} else if (exception === 'abort') {
alert('Ajax request aborted.');
} else {
alert('Uncaught Error. ' + jqXHR.responseText);
}
}
});
$.get('/bitrix/templates/dveri/ajax/count_basket.php').done(function(data){
data = $.parseJSON(data);
$('#tt').text(data);
});
});
});
[STATUS] => Array
(
[ID] => 281
[TIMESTAMP_X] => 2020-07-15 09:23:11
[IBLOCK_ID] => 70
[NAME] => Статус брони
[ACTIVE] => Y
[SORT] => 500
[CODE] => STATUS
[DEFAULT_VALUE] => QPhiX2EE
[PROPERTY_TYPE] => S
[ROW_COUNT] => 1
[COL_COUNT] => 30
[LIST_TYPE] => L
[MULTIPLE] => N
[XML_ID] =>
[FILE_TYPE] =>
[MULTIPLE_CNT] => 5
[TMP_ID] =>
[LINK_IBLOCK_ID] => 0
[WITH_DESCRIPTION] => N
[SEARCHABLE] => N
[FILTRABLE] => N
[IS_REQUIRED] => N
[VERSION] => 1
[USER_TYPE] => directory
[USER_TYPE_SETTINGS] => Array
(
[size] => 1
[width] => 0
[group] => N
[multiple] => N
[TABLE_NAME] => b_hlbd_status
)
[HINT] =>
[PROPERTY_VALUE_ID] => 12512
[VALUE] => Array
(
[0] => 0TGTVKws
)
[DESCRIPTION] =>
[VALUE_ENUM] =>
[VALUE_XML_ID] =>
[VALUE_SORT] =>
[~VALUE] => 0TGTVKws
[~DESCRIPTION] =>
[~NAME] => Статус брони
[~DEFAULT_VALUE] => QPhiX2EE
)
document.getElementById('price').value=this.currentPrices[this.currentPriceSelected];