Answer the question
In order to leave comments, you need to log in
How to add the required number of products to the Bitrix cart?
Good afternoon! Please tell me how to solve this problem.
In 1s Bitrix, when a product has a trade offer, then when it is added to the cart, it is added one at a time.
With a simple product, this problem does not arise. I can't figure out why this is happening.
Answer the question
In order to leave comments, you need to log in
Excuse me, but how do you think it should happen?
SKU is not a kit and not a set, why would it be added more than one?
Let's deal with the entities
Trade offer
Sets
Sets
https://dev.1c-bitrix.ru/learning/course/index.php...
Maybe it's clumsy, but it all worked.
Through ajax, I passed the product data: id and quantity to the addbasket file, which I created in the template for the site. You can shove it elsewhere.
addbasket.php code
<? require_once ($_SERVER['DOCUMENT_ROOT']."/bitrix/modules/main/include.php");?>
<?
if (CModule::IncludeModule("sale") && CModule::IncludeModule("catalog")){
if (isset($_POST['id'])&&isset($_POST['quantity'])) {
$PRODUCT_ID = intval($_POST['id']);
$QUANTITY = intval($_POST['quantity']);
Add2BasketByProductID(
$PRODUCT_ID,
$QUANTITY,
'VALUE'=>$_POST['roll']
]
]
);
LocalRedirect("/personal/cart/"); //path in your cart
}
else {
echo "No parameters";
}
}
else {
echo "No modules connected";
}
?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question