Last active
September 10, 2020 18:36
-
-
Save YuriDan/7c4a75093eaf3939bd6a to your computer and use it in GitHub Desktop.
Получить скидки товара, включая правила работы с корзиной
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$dbBasketItems = CSaleBasket::GetList( | |
array("ID" => "ASC"), | |
array( | |
'FUSER_ID' => CSaleBasket::GetBasketUserID(), | |
'LID' => SITE_ID, | |
'ORDER_ID' => 'NULL' | |
), | |
false, | |
false, | |
array( | |
'ID', 'PRODUCT_ID', 'QUANTITY', 'PRICE', 'DISCOUNT_PRICE', 'WEIGHT' | |
) | |
); | |
$allSum = 0; | |
$allWeight = 0; | |
$arItems = array(); | |
while ($arBasketItems = $dbBasketItems->Fetch()) | |
{ | |
$allSum += ($arItem["PRICE"] * $arItem["QUANTITY"]); | |
$allWeight += ($arItem["WEIGHT"] * $arItem["QUANTITY"]); | |
$arItems[] = $arBasketItems; | |
} | |
$arOrder = array( | |
'SITE_ID' => SITE_ID, | |
'USER_ID' => $GLOBALS["USER"]->GetID(), | |
'ORDER_PRICE' => $allSum, | |
'ORDER_WEIGHT' => $allWeight, | |
'BASKET_ITEMS' => $arItems | |
); | |
$arOptions = array( | |
'COUNT_DISCOUNT_4_ALL_QUANTITY' => 'Y', | |
); | |
$arErrors = array(); | |
CSaleDiscount::DoProcessOrder($arOrder, $arOptions, $arErrors); | |
$PRICE_ALL = 0; | |
$DISCOUNT_PRICE_ALL = 0; | |
$QUANTITY_ALL = 0; | |
foreach ($arOrder["BASKET_ITEMS"] as $arOneItem) | |
{ | |
$PRICE_ALL += $arOneItem["PRICE"] * $arOneItem["QUANTITY"]; | |
$DISCOUNT_PRICE_ALL += $arOneItem["DISCOUNT_PRICE"] * $arOneItem["QUANTITY"]; | |
$QUANTITY_ALL += $arOneItem['QUANTITY']; | |
} | |
$result['PRICE_ALL'] = $PRICE_ALL; | |
$result['DISCOUNT_PRICE_ALL'] = $DISCOUNT_PRICE_ALL; | |
$result['QUANTITY_ALL'] = $QUANTITY_ALL; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Не считает наценку из правил корзины