From ebb32869aa5754333f19449a16efb6f18bbf4777 Mon Sep 17 00:00:00 2001 From: Kocmonavtik <61938582+Kocmonavtik@users.noreply.github.com> Date: Thu, 18 Jul 2024 14:14:36 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BF=D0=B5=D1=80=D0=B5=D0=B4=D0=B0=D1=87=D0=B0?= =?UTF-8?q?=20=D1=81=D0=BA=D0=B8=D0=B4=D0=BE=D0=BA=20=D0=BD=D0=B0=20=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=B3=D0=BE=D0=B2=D1=8B=D0=B5=20=D0=BF=D0=BE=D0=B7?= =?UTF-8?q?=D0=B8=D1=86=D0=B8=D0=B8=20=D0=B2=20=D0=B1=D1=80=D0=BE=D1=88?= =?UTF-8?q?=D0=B5=D0=BD=D0=BD=D1=8B=D1=85=20=D0=BA=D0=BE=D1=80=D0=B7=D0=B8?= =?UTF-8?q?=D0=BD=D0=B0=D1=85=20(#353)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 3 ++ .../classes/general/cart/RetailCrmCart_v5.php | 28 +++++++++++++++---- .../classes/general/config/retailcrm.json | 2 +- intaro.retailcrm/description.ru | 2 +- intaro.retailcrm/install/version.php | 4 +-- 5 files changed, 29 insertions(+), 10 deletions(-) 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' ];