Answer the question
In order to leave comments, you need to log in
How to add a custom field to the cart?
You need to add a text field to the cart. Not a product property, but a separate field in the cart - so that it is filled in on the cart page, but then saved as an order property. What is the best way to do this?
Answer the question
In order to leave comments, you need to log in
So do it:
1. Add a field:
<input type="text" value="Моё отдельное поле">
Pass the value of this field through cookies or through the form using the post method in the code below
2. Update the order properties:
$order = \Bitrix\Sale\Order::load(123); //загрузим номер созданного заказа
$collection = $order->getPropertyCollection();
$propertyValue = $collection->getItemById(10);//id свойства
$r = $propertyValue->setField('VALUE', 'Моё отдельное поле');
if (!$r->isSuccess())
{
var_dump($r->getErrorMessages());
}
$order->save();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question