1С-Битрикс
1
Вклад в тег
<?$fuserId = CSaleBasket::GetBasketUserID();
$dbBasketItems = CSaleBasket::GetList(
array("ID" => "ASC"),
array(
"FUSER_ID" => $fuserId,
"LID" => SITE_ID,
"ORDER_ID" => "NULL",
"DELAY"=>"N"
),
false,
false,
array(
"ID", "NAME", "CALLBACK_FUNC", "MODULE", "PRODUCT_ID", "PRODUCT_PRICE_ID", "QUANTITY", "DELAY", "CAN_BUY",
"PRICE", "WEIGHT", "DETAIL_PAGE_URL", "NOTES", "CURRENCY", "VAT_RATE", "CATALOG_XML_ID",
"PRODUCT_XML_ID", "SUBSCRIBE", "DISCOUNT_PRICE", "PRODUCT_PROVIDER_CLASS", "TYPE", "SET_PARENT_ID"
)
);
while ($arBasketItems = $dbBasketItems->Fetch())
{
$allSum = ($arBasketItems["PRICE"] * $arBasketItems["QUANTITY"]);
$allWeight = ($arBasketItems["WEIGHT"] * $arBasketItems["QUANTITY"]);
$arResult[] = $arBasketItems;
}
$arOrder = array(
'SITE_ID' => SITE_ID,
'USER_ID' => $GLOBALS["USER"]->GetID(),
'ORDER_PRICE' => $allSum, // сумма всей корзины
'ORDER_WEIGHT' => $allWeight, // вес всей корзины
'BASKET_ITEMS' => $arResult // товары сами
);
$arOptions = array(
'COUNT_DISCOUNT_4_ALL_QUANTITY' => "Y",
);
$arErrors = array();
CSaleDiscount::DoProcessOrder($arOrder, $arOptions, $arErrors);
echo $arOrder["ORDER_PRICE"];?>
<?$basket = \Bitrix\Sale\Basket::loadItemsForFUser(
\Bitrix\Sale\Fuser::getId(),
\Bitrix\Main\Context::getCurrent()->getSite()
); // текущая корзина
$fuser = new \Bitrix\Sale\Discount\Context\Fuser($basket->getFUserId(true));
$discounts = \Bitrix\Sale\Discount::buildFromBasket($basket, $fuser);
$discounts->calculate();
$result = $discounts->getApplyResult(true);
$prices = $result['PRICES']['BASKET']; // цены товаров с учетом скидки
print_r($prices);
foreach ($prices as $price):
//echo $price[PRICE];?><br>
<?
$summs[]=$price[PRICE];
?>
<?endforeach;?>
<?
$a = array($summs);
$summsss = array_sum($summs);
echo $summsss;?>