$params = json_decode($params["params"]);
$PRODUCT_ID = $params->product_id;
$dbBasketItems = CSaleBasket::GetList(
array(
"NAME" => "ASC",
"ID" => "ASC"
),
array(
"FUSER_ID" => CSaleBasket::GetBasketUserID(),
"LID" => SITE_ID,
"ORDER_ID" => "NULL"
),
false,
false,
array("ID",'PRODUCT_ID')
);
$ID_TO_BASKET = false;
while ($arItems = $dbBasketItems->Fetch())
{
if($arItems['PRODUCT_ID'] == $PRODUCT_ID){
$ID_TO_BASKET = $arItems['ID'];
break;
}
}
$result["ID_TO_BASKET"] = $ID_TO_BASKET;
if($ID_TO_BASKET == false){
global $USER;
$PRICE_TYPE_ID = 2;
if($USER->IsAuthorized() && !strpos($USER->GetUserGroupString(),'6') === false){
$PRICE_TYPE_ID = 3;
}
$db_res = CPrice::GetList(
array(),
array(
"PRODUCT_ID" => $PRODUCT_ID,
"CATALOG_GROUP_ID" => $PRICE_TYPE_ID
)
);
$prices = $db_res->Fetch();
if(!isset($prices) or empty($prices)){
$prices = CPrice::GetBasePrice($PRODUCT_ID);
}
$elementDb = CIBlockElement::GetByID($PRODUCT_ID);
$item = $elementDb->GetNext();
$arFields = array(
"PRODUCT_ID" => $PRODUCT_ID,
"PRICE" => number_format($prices['PRICE'], 0, '.', ''),
"LID" => SITE_ID,
"NAME" => $item['NAME'],
"CURRENCY" => "RUB",
"QUANTITY" => 1,
"WEIGHT" => $item['WEIGHT'],
"DIMENSIONS" => array(
"WIDTH" => $item["WIDTH"],
"HEIGHT" => $item["HEIGHT"],
"LENGTH" => $item["LENGTH"],
)
);
$result["NEW_BASKET_ID"] = CSaleBasket::Add($arFields);
}else{
if($params->quantity > 0){
$arFields = array(
"QUANTITY" => $params->quantity
);
CSaleBasket::Update($ID_TO_BASKET, $arFields);
}else{
CSaleBasket::Delete($ID_TO_BASKET);
}
}
$dbBasketItems = CSaleBasket::GetList(
array(
"NAME" => "ASC",
"ID" => "ASC"
),
array(
"FUSER_ID" => CSaleBasket::GetBasketUserID(),
"LID" => SITE_ID,
"ORDER_ID" => "NULL"
),
false,
false,
array("QUANTITY", "PRICE")
);
$items = 0;
$quantity = 0;
$price = 0;
while ($arItems = $dbBasketItems->Fetch())
{
$items++;
$quantity = $quantity+$arItems["QUANTITY"];
$price = $price+($arItems["QUANTITY"]*$arItems["PRICE"]);
}
$result["items"] = $items;
$result["quantity"] = $quantity;
$result["price"] = $price;
echo json_encode($result);
$params = json_decode($params["params"]);
$PRODUCT_ID = $params->product_id;
$PRICE_TYPE_ID = 2;
if($USER->IsAuthorized() && !strpos($USER->GetUserGroupString(),'6') === false){
$PRICE_TYPE_ID = 3;
}
$elementDb = CIBlockElement::GetByID($PRODUCT_ID);
$item = $elementDb->GetNext();
$db_res = CPrice::GetList(
array(),
array(
"PRODUCT_ID" => $PRODUCT_ID,
"CATALOG_GROUP_ID" => $PRICE_TYPE_ID
)
);
$prices = $db_res->Fetch();
if(!isset($prices) or empty($prices)){
$prices = CPrice::GetBasePrice($PRODUCT_ID);
}
$arFields = array(
"PRODUCT_ID" => $PRODUCT_ID,
"PRICE" => number_format($prices['PRICE'], 0, '.', ''),
"LID" => SITE_ID,
"NAME" => $item['NAME'],
"CURRENCY" => "RUB",
"QUANTITY" => 1,
"WEIGHT" => $item['WEIGHT'],
"DIMENSIONS" => array(
"WIDTH" => $item["WIDTH"],
"HEIGHT" => $item["HEIGHT"],
"LENGTH" => $item["LENGTH"],
)
);
$result = CSaleBasket::Add($arFields);
SELECT * FROM Table_1 INNER JOIN Table_2 using(DATE)
или
SELECT * FROM Table_1, Table_2 WHERE Table_1.DATE = Table_2.DATE;
$(document).ready(function () {
$(document).on("click","[data-triger-class]",function(e){
e.preventDefault();
let target = $(this).data('triger-class');
if($('.'+target).hasClass('active')){
$('.trigger' ).removeClass('active');
}else{
$('.trigger' ).removeClass('active');
$('.'+target).addClass('active');
}
});
});
2) Запоминайте текущий скрол и после подгрузки устанавливайте в текущее положение