$basket = \Bitrix\Sale\Basket::loadItemsForFUser(\Bitrix\Sale\Fuser::getId(), \Bitrix\Main\Context::getCurrent()->getSite());
$basketItems = $basket->getBasketItems();
foreach ($basketItems as $product) {
if(intval($product->getId()) == $itemId){
$res = \CIBlockElement::GetList(
array(),
array('IBLOCK_ID' => CATALOG_IBLOCK_ID, '=ACTIVE' => 'Y', "ID" => $product->getProductId()),
false,
false,
array("QUANTITY")
);
$item = $res->fetch();
if((floor(floatval($item["QUANTITY"])) - floatval($quantity)) < 0){
$quantity = floor(floatval($item["QUANTITY"]));
}
$product->setField('QUANTITY', $quantity);
$basket->save();
return jsonAnswerSuccess("UPDATE_QUANTITY_SUCCESS");
}
}
throw new Exception('PRODUCT_NOT_FOUND_IN_CART');
}
Есть к чему придратся?
запрлс в цикле например
Обсуждают сегодня