Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
Sparvka on this event. It occurs before the end of the recalculation of the cost of the basket
https://dev.1c-bitrix.ru/api_d7/bitrix/sale/events...
/// checking users to apply the coupon WELCOME10
\Bitrix\Main\EventManager::getInstance()- >addEventHandler(
'sale', 'OnBeforeSaleOrderFinalAction', 'chkCupon'
);
function chkCupon(Bitrix\Main\Event $event) {
$groupId = 10;
$couponName = 'WELCOME10';
$order = $event->getParameter("ENTITY");
$arOrderVals = $order->getFields()->getValues();
$orderId = $arOrderVals['ID'];
$userId = $order->getUserId();
$discountData = $order->getDiscount()->
if (key($discountData['COUPON_LIST']) == $couponName) {
$arGroups = CUser::GetUserGroup($userId);
unset($arGroups[array_search($groupId, $arGroups)]);
CUser::SetUserGroup($userId, $arGroups);
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question