How to add a property to cart into Bitrix?

In the item card has a property of type list, multiple. Appears this way:
<? if ($arResult["PROPERTIES"]["DIMENSIONS"]["VALUE"]) { ?>
 <div class="catalog-detail__options">
 <select name="size">
 <option disabled><?=GetMessage("SELECT_SIZE")?></option>
 <? foreach($arResult["PROPERTIES"]["DIMENSIONS"]["VALUE"] as $size) { ?>
 <option value="<?=$size?>"><?=$size?></option>
 <? } ?>
</select>
</div>
 <? } ?>

How to pass it in the bin?
That is, at the moment it is transmitted, but is transmitted in its entirety all, that is, if you specify a single size, it still passed the array of all sizes.
June 3rd 19 at 19:02
2 answers
June 3rd 19 at 19:04
One of the sites we have approximately made through the api
Add2BasketByProductID(
$PRODUCT_ID,
1,
array(
array("CODE" => "DIMENSIONS", "NAME" => "Size", "VALUE" => $_POST['size']),
)
);

You need to pass product id, quantity, code property name (and the name randomly is even possible), and the VALUE to pass something jabbed the user, i.e., the size of. I have made it through $_POST. I think the point is clear
The bottom line is clear for a long time, but how to convey?
item id, quantity supplied, the size of the same is transmitted, but the entire array, property, multiple, and Yes, if you choose one size that all passed, Hz. why. - Camilla36 commented on June 3rd 19 at 19:07
which method use to send the product to the cart? - Nedra3 commented on June 3rd 19 at 19:10
If I'm in the right direction was, but kind of in the right because if you remove this piece of code that doesn't work. In the file scripts.js there is such a fragment, the method ADD2BASKET out?:
$('.add-to-cart-btn').click(function(){
 var id = $(this).data('id');
 var quantity = $('.quantity-value').val();
$(this).addClass('pending');
$.ajax({
 type: 'POST',
 url: '?action=ADD2BASKET&id='+id+'&quantity='+quantity,
 data: ",
 success: function(){
$('.add-to-cart-btn').removeClass('pending');
$.ajax({
 type: 'POST',
 url: '/ajax.handler.php',
 data: 'PAGE=CART',
 success: function(data){
$('.header__cart-num').hide().html(data).fadeIn();
}
});
 var itemTitle = $('h1').text();
 $('.order-notification__title').text(itemTitle+' added to cart!');
 $('.order-notification').fadeIn().animate({'marginRight': '0'});
},
error:function(){
}
});
 });
- Camilla36 commented on June 3rd 19 at 19:13
How to make on js I don't know as not good at it.
But apparently missing arProductParams
Can you help this article
https://dev.1c-bitrix.ru/api_help/catalog/basket.php - Nedra3 commented on June 3rd 19 at 19:16
June 3rd 19 at 19:06
Like it's not in JS because still passed without it. In the basket there is such code:
<?require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");?>
<?if(!empty($_GET["act"]) && CModule::IncludeModule("catalog") && CModule::IncludeModule("sale") && CModule::IncludeModule("iblock")){

 if($_GET["act"] == "upd"){
 echo CSaleBasket::Update(intval($_GET['id']), array(
 "QUANTITY" =--> intval($_GET["q"]),
 "DELAY" => "N"
));
 }elseif($_GET["act"] == "del"){
 echo CSaleBasket::Delete(intval($_GET['id']));
 }elseif($_GET["act"] == "updDeliveryPayment"){

if(!empty($_GET["DEVIVERY_TYPE"])){
 $delivery_type = $_GET["DEVIVERY_TYPE"];
}
if(!empty($_GET["PAY_TYPE"])){
 $pay_type = $_GET["PAY_TYPE"];
}
if(!empty($_GET["receive_address"])){
 $receive_address = $_GET["receive_address"];
}

 $arBasketItems = array();
 $arBasketOrder = array("NAME" => "ASC", "ID" => "ASC");
 $arBasketUser = array("FUSER_ID" => CSaleBasket::GetBasketUserID(), "LID" => SITE_ID, "ORDER_ID" => "NULL");
 $arBasketSelect = array("ID", "CALLBACK_FUNC", "MODULE", "PRODUCT_ID", "QUANTITY", "DELAY",
 "CAN_BUY", "PRICE", "WEIGHT", "NAME", "CURRENCY", "CATALOG_XML_ID", "VAT_RATE",
 "NOTES", "DISCOUNT_PRICE", "PRODUCT_PROVIDER_CLASS", "DIMENSIONS", "TYPE", "SET_PARENT_ID", "DETAIL_PAGE_URL", "*"
);
 $dbBasketItems = CSaleBasket::GetList($arBasketOrder, $arBasketUser, false, false, $arBasketSelect);

 while ($arItems = $dbBasketItems->Fetch()){

 $arResult["PRODUCTS_CART"][] = $arItems;

 $arResult["SUM"] += $arItems['PRICE'] * $arItems['QUANTITY'];

}


 $arD2P = array();
 $arP2D = array();
 $payment_ids = array();
 $delivery_ids = array();

etc.
Here's the code, just checked, adds to cart a product with a property:
<?
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");
CModule::IncludeModule("catalog");
Add2BasketByProductID(
 30949, //specify the ID of the real item
1,
array(
array("CODE" =--> "DIMENSIONS", "NAME" => "Size", "VALUE" => XXL),
)
);
?>

create a page, place this code, run it, see the basket, the property and product have? If so, use this method in the template the item card. - Camilla36 commented on June 3rd 19 at 19:09

Find more questions by tags 1C-Bitrix