Answer the question
In order to leave comments, you need to log in
Is it possible to add several trading offers to the cart using regular Bitrix tools?
Trade offers - TP.
The product has several TPs (highlighted in red on the screen). Trees differ in size and the user wants to buy 2 types of goods. 5 high and 10 low for example. Having selected the required quantity, you need to click on the "Add to cart" button to add both of these TPs to the cart.
dl4.joxi.net/drive/2018/06/29/0014/0665/971417/17/...
Answer the question
In order to leave comments, you need to log in
In the old kernel this was fairly easy to do from the normal trade directory functions.
The new core has new methods for working with adding items to the cart, and some of them are replacements for the old ones.
All you need is to get a list of products in one place and send a request to your page, where you will add this product to the basket (or you can send one request for each item to the basket script).
You knock with an array of data to the script that you add to the cart, there you update product by product in turn.
It turned out something like this.
JS collect ID and quantity. I collect it into an object and transfer it to a php file.
<?
include($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");
CModule::IncludeModule("catalog");
$result=array();
$quantity=1;
foreach ($_POST as $key => $value) {
if($value['quantity']>1){
$quantity=$value['quantity'];
}
if(Add2BasketByProductID($value['id'], $quantity)){
$result[]=$value['id'];
}else{
$result['error'][]=$value['id'];
}
}
echo json_encode($result);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question