diff --git a/CHANGELOG.md b/CHANGELOG.md index c0bfd994..a2860eb1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 2024-07-18 v.6.5.22 +- Добавлена передача скидок на торговые позиции в брошенных корзинах + ## 2024-07-15 v.6.5.21 - Добавлена передача поля link при выгрузке брошенных корзин diff --git a/intaro.retailcrm/classes/general/cart/RetailCrmCart_v5.php b/intaro.retailcrm/classes/general/cart/RetailCrmCart_v5.php index a6089ddd..464b8afa 100644 --- a/intaro.retailcrm/classes/general/cart/RetailCrmCart_v5.php +++ b/intaro.retailcrm/classes/general/cart/RetailCrmCart_v5.php @@ -11,6 +11,8 @@ use Bitrix\Main\Context\Culture; use Bitrix\Sale\Basket; +use Bitrix\Sale\Discount\Context\Fuser; +use Bitrix\Sale\Discount; IncludeModuleLangFile(__FILE__); @@ -128,14 +130,28 @@ class RetailCrmCart return null; } - $arBasket = [ - 'LID' => $obBasket->getSiteId(), - ]; - $items = $obBasket->getBasket(); + $arBasket = ['LID' => $obBasket->getSiteId()]; - foreach ($items as $item) { - $arBasket['BASKET'][] = $item->getFields(); + if (count($items) !== 0) { + $fUser = new Fuser($obBasket->getFUserId()); + $discounts = Discount::buildFromBasket($obBasket, $fUser); + + $discounts->calculate(); + + $resultBasket = $discounts->getApplyResult(true); + $basketItems = $resultBasket['PRICES']['BASKET'] ?? []; + + + foreach ($items as $item) { + $itemFields = $item->getFields(); + + if (isset($basketItems[(int) $itemFields['ID']])) { + $itemFields['PRICE'] = $basketItems[(int) $itemFields['ID']]['PRICE']; + } + + $arBasket['BASKET'][] = $itemFields; + } } return $arBasket; diff --git a/intaro.retailcrm/classes/general/config/retailcrm.json b/intaro.retailcrm/classes/general/config/retailcrm.json index af57234e..20f27eb0 100644 --- a/intaro.retailcrm/classes/general/config/retailcrm.json +++ b/intaro.retailcrm/classes/general/config/retailcrm.json @@ -449,7 +449,7 @@ "type": "double", "default": 0, "min": 0, - "decimals": 1 + "decimals": 2 }, "code": { "type": "string" diff --git a/intaro.retailcrm/description.ru b/intaro.retailcrm/description.ru index 64484a9b..d227687c 100644 --- a/intaro.retailcrm/description.ru +++ b/intaro.retailcrm/description.ru @@ -1 +1 @@ -- Добавлена передача поля link при выгрузке брошенных корзин +- Добавлена передача скидок на торговые позиции в брошенных корзинах diff --git a/intaro.retailcrm/install/version.php b/intaro.retailcrm/install/version.php index 16f903d2..1d29c20b 100644 --- a/intaro.retailcrm/install/version.php +++ b/intaro.retailcrm/install/version.php @@ -1,6 +1,6 @@ '6.5.21', - 'VERSION_DATE' => '2024-07-15 17:00:00' + 'VERSION' => '6.5.22', + 'VERSION_DATE' => '2024-07-18 12:00:00' ];