Changing the verification to update the properties of the loyalty program order
This commit is contained in:
parent
1d5bb5b061
commit
552f5c602f
2 changed files with 11 additions and 14 deletions
|
@ -1185,8 +1185,6 @@ class RetailCrmHistory
|
|||
}
|
||||
}
|
||||
|
||||
EventsHandlers::$disableSaleHandler = true;
|
||||
|
||||
$newOrder->setField('PRICE', $orderSumm);
|
||||
self::orderSave($newOrder);
|
||||
|
||||
|
@ -1224,8 +1222,6 @@ class RetailCrmHistory
|
|||
self::orderSave($newOrder);
|
||||
}
|
||||
|
||||
EventsHandlers::$disableSaleHandler = false;
|
||||
|
||||
if (!empty($deleteBasketInfo)) {
|
||||
$orderLoyaltyDataService->deleteLoyaltyInfoFromHl($deleteBasketInfo);
|
||||
}
|
||||
|
|
|
@ -127,11 +127,18 @@ class EventsHandlers
|
|||
*/
|
||||
public function OnSaleOrderSavedHandler(Event $event): void
|
||||
{
|
||||
if (self::$disableSaleHandler === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$isBonusInput = (
|
||||
!empty($_POST['bonus-input'])
|
||||
&& !empty($_POST['available-bonuses'])
|
||||
);
|
||||
|
||||
$isDataForLoyaltyDiscount = isset($_POST['calculate-items-input'], $_POST['loyalty-discount-input']);
|
||||
|
||||
if (self::$disableSaleHandler === true || !($isDataForLoyaltyDiscount || $isBonusInput) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* @var LoyaltyService $loyaltyService */
|
||||
$loyaltyService = ServiceLocator::get(LoyaltyService::class);
|
||||
|
||||
|
@ -144,17 +151,11 @@ class EventsHandlers
|
|||
$saveResult = RetailCrmEvent::orderSave($order);
|
||||
Utils::handleApiErrors($saveResult);
|
||||
|
||||
$isBonusInput = (
|
||||
!empty($_POST['bonus-input'])
|
||||
&& !empty($_POST['available-bonuses'])
|
||||
);
|
||||
|
||||
$bonusFloat = (float) $_POST['bonus-input'];
|
||||
|
||||
/** @var bool $isNewOrder */
|
||||
$isNewOrder = $event->getParameter('IS_NEW');
|
||||
$isLoyaltyOn = ConfigProvider::getLoyaltyProgramStatus() === 'Y';
|
||||
$isDataForLoyaltyDiscount = isset($_POST['calculate-items-input'], $_POST['loyalty-discount-input']);
|
||||
$isBonusesIssetAndAvailable = $isBonusInput && (float) $_POST['available-bonuses'] >= $bonusFloat;
|
||||
|
||||
/** @var array $calculateItemsInput */
|
||||
|
|
Loading…
Add table
Reference in a new issue