Answer the question
In order to leave comments, you need to log in
Add2BasketByProductID refuses to add properties?
subject.
We need to add properties coming from the front via AJAX. I act as it is written in the documentation:
if (!Add2BasketByProductID($_REQUEST["item"], $_REQUEST["quantity"], array(), array(
array(
"NAME" => "Цвет",
"CODE" => "CLR",
"VALUE" => "красный"
)
))) {
if ($ex = $APPLICATION->GetException())
$strErrorExt = $ex->GetString();
$strError = "ERROR_ADD2BASKET";
$successfulAdd = false;
}
Answer the question
In order to leave comments, you need to log in
Use the new API.
Examples of working with a shopping cart and cart properties
Getting a BUYER 's cart
/*
* $fuser - ID пользователя
* $siteId - ID сайта, к которому привязана корзина
*/
$basket = \Bitrix\Sale\Basket::loadItemsForFUser($fuser, $siteId);
$basketItem = $basket->createItem($moduleId, $productId);
$basketItem->setField('QUANTITY', 4);
$collection = $basketItem->getPropertyCollection();
$item = $collection->createItem();
$item->setFields([
'NAME' => 'Новое свойство',
'CODE' => 'XXX',
'VALUE' => 'Значение',
]);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question