E
E
Eugene M2018-07-22 22:47:13
1C-Bitrix
Eugene M, 2018-07-22 22:47:13

How to add a product property to the cart in Bitrix?

The product card has a property of type list, multiple. It is output in 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 transfer it to the basket?
That is, at the moment it is being transferred, but everything is being transferred completely, that is, if you specify one size, then an array of all sizes will still be transferred.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton, 2018-07-23
@anton99zel

On one of the sites we have done something like this, through api

Add2BasketByProductID(
      $PRODUCT_ID,
      1,
array(
array("CODE" => "DIMENSIONS", "NAME" => "Размер", "VALUE" => $_POST['size']),
 )
);

You need to pass the product id, quantity, property code, name (even a random name is possible), and in VALUE pass what the user has poked, i.e. the size. At me it is made through $_POST. I think the point is clear

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question