Answer the question
In order to leave comments, you need to log in
How to display in the cart a property added along with a product (Bitrix)?
Hello. I set up in Bitrix the ability to add a product to the cart, indicating an additional property: the user enters any text and sends the product with it to the cart.
I have placed a text field on the product page. I set it up so that the values from it fall into the admin panel, but I can’t find a solution how to display this text in the basket.
The code that is responsible for adding the product to the cart:
Add2BasketByProductID($PRODUCT_ID, 1, array(
array("NAME" => "Текст для нанесения", "CODE" => "CUSTOMTEXT", "VALUE" => $_POST['custom-text'])
) );
foreach ($basket as $basketItem) {
$productid = $basketItem->getProductId();
$goodID = getElementByID($productid);
$items[$productid] = [
'id' => $basketItem->getProductId(),
'basket_id' => $basketItem->getId(),
...
'customtext' => isset($goodID['PROPS']['CUSTOMTEXT']) ? $goodID['PROPS']['CUSTOMTEXT']['VALUE'] : '',
...
]
Answer the question
In order to leave comments, you need to log in
Are you setting the element's property to the value that the user enters? It’s really not worth doing this (case: 2 people went to the site, both entered different text, what will be displayed for whom?).
Cart items have a NOTES field, fill it out when adding goods to the cart, then you won’t have to mess with the template (as far as I remember, the standard one displays). If not, then just add the output of this field to the template.
Documentation: https://dev.1c-bitrix.ru/api_d7/bitrix/sale/techni...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question