$q = trim($_REQUEST["q"]);
надо будёт $q очистить от ненужных символов, как делали выше. Bitrix\Main\Page\Asset::getInstance()->addJs("/path/to/script/file.js");
$user = new CUser;
$fields = Array(
"UF_PROPERTY_CODE" => "value",
);
$user->Update($ID, $fields);
/*
* $fuser - ID пользователя
* $siteId - ID сайта, к которому привязана корзина
*/
$basket = \Bitrix\Sale\Basket::loadItemsForFUser($fuser, $siteId);
$basketItem = $basket->createItem($moduleId, $productId);
$basketItem->setField('QUANTITY', 4);
$collection = $basketItem->getPropertyCollection();
$item = $collection->createItem();
$item->setFields([
'NAME' => 'Новое свойство',
'CODE' => 'XXX',
'VALUE' => 'Значение',
]);
$coupon = DiscountCouponTable::generateCoupon(true);
//$activeFrom = new \Bitrix\Main\Type\DateTime;
//$activeTo = clone $activeFrom;
$addDb = DiscountCouponTable::add(array(
'DISCOUNT_ID' => $saleDiscountId,//ID скидки
//'ACTIVE_FROM' => $activeFrom,
//'ACTIVE_TO' => $activeTo->add('+365 days'),
'COUPON' => $coupon,
'TYPE' => \Bitrix\Sale\Internals\DiscountCouponTable::TYPE_ONE_ORDER,
'MAX_USE' => 1,
'USER_ID' => $USER->GetID(),
'DESCRIPTION' => 'описание купона',
));
public static function add(array $data)
{
$result = new ORM\Data\AddResult();
$result->addError(new ORM\EntityError(
Loc::getMessage('ELEMENT_ENTITY_MESS_ADD_BLOCKED')
));
return $result;
}
public static function update($primary, array $data)
{
$result = new ORM\Data\UpdateResult();
$result->addError(new ORM\EntityError(
Loc::getMessage('ELEMENT_ENTITY_MESS_UPDATE_BLOCKED')
));
return $result;
}
public static function delete($primary)
{
$result = new ORM\Data\DeleteResult();
$result->addError(new ORM\EntityError(
Loc::getMessage('ELEMENT_ENTITY_MESS_DELETE_BLOCKED')
));
return $result;
}
Метод заблокирован. Используйте метод CIBlockElement::Update
public static function addTrackingUrlToMail(&$event, &$lid, &$arFields)
{
if ($event == "SALE_ORDER_TRACKING_NUMBER") {
$order = \Bitrix\Sale\Order::load($arFields["ORDER_REAL_ID"]);
$shipmentCollection = $order->getShipmentCollection();
/* @var $shipmentColletion \Bitrix\Sale\ShipmentCollection */
$deliveryId = 0;
foreach ($shipmentCollection as $shipment) {
/* @var $shipment \Bitrix\Sale\Shipment */
if (!$shipment->isSystem()) {
$delivery = $shipment->getDelivery();
$deliveryId = $delivery->getParentId();
$arFields["DELIVERY_NAME"] = $delivery->getNameWithParent();
}
}
$urlTemplate = "<a href='%s'>%s</a>";
$trackMessage = "";
if (\Gricuk\Sale\Delivery\Helper::isRussianPostDelivery($deliveryId)) {
$trackUrl = "https://www.pochta.ru/tracking#{$arFields["ORDER_TRACKING_NUMBER"]}";
$trackMessage = sprintf($urlTemplate, $trackUrl, $trackUrl);
} else {
switch ($deliveryId) {
case Conf::ID_DELIVERY_CDEK://ID службы доставки СДЕК
$trackUrl = "https://www.cdek.ru/track.html?order_id={$arFields["ORDER_TRACKING_NUMBER"]}";
$trackMessage = sprintf($urlTemplate, $trackUrl, $trackUrl);
break;
}
}
$arFields["TRACK_URL"] = $trackMessage;
}
}
$customFields = [];//Ваши данные
/** @var CBitrixComponent $component */
$component = $this->__component;
$component->setResultCacheKeys(["CUSTOM_FIELDS"]);
global $customFields ;
$customFields = $arResult["CUSTOM_FIELDS"];