Answer the question
In order to leave comments, you need to log in
How to add several products to the cart in Bitrix?
I have a product, this product has two "binding to elements" properties.
Those. I have an array with three IDs, this is a product ID and two element IDs by "binding".
You need to click on the button, transfer all these IDs to the basket. Making a button:
<a href="<?=$item['DETAIL_PAGE_URL'];?>&add2basket.php?quantity=1&action=ADD2BASKET&id=<?= $item['PROPERTIES']['PROP-1']['VALUE'] ?>&add2basket.php?quantity=1&action=ADD2BASKET&id=<?= $item['PROPERTIES']['PROP-2']['VALUE']&add2basket.php?quantity=1&action=ADD2BASKET&id=<?= $item['PROPERTIES']['PROP-3']['VALUE'] ?>" rel="nofollow" onclick="return addToCart(this');"><span class="add-basket"></span>В корзину</a>
Answer the question
In order to leave comments, you need to log in
<?require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");
//смотрим что приходит сюда
print_r($_POST);
//подключаем модули магазина и каталога
if (CModule::IncludeModule("sale") && CModule::IncludeModule("catalog")) {
//Добавляем основной товар, указываем в переменной его id и количество 1 штука
Add2BasketByProductID( $_POST[main], 1 );
//Добавляем дополнительный товар в количестве 5 штук
Add2BasketByProductID($_POST[more], 5,
array(
//Перечисляем свойства, например цвет
array("CODE" => "COLOR", "NAME" => "Цвет", "VALUE" => $_POST[COLOR])
)
);
//Добаляем еще один доптовар
Add2BasketByProductID($_POST[more2], 1,
array(
//и свойства
array("CODE" => "COLOR", "NAME" => "Цвет", "VALUE" => $_POST[COLOR])
)
);
//идём в корзину
LocalRedirect('/personal/cart/');
}else { echo "Не подключены модули"; }
?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question