Answer the question
In order to leave comments, you need to log in
How to withdraw the order amount?
Hello. There is a site 9ruk.ru, there is "Suma" in the header on the right. This is text for now.
How can I bind a variable here?
Here's what happened before:
<div class="foot_panel_2">
<?$APPLICATION->IncludeComponent("bitrix:sale.basket.basket.line", ".default",
array(
"PATH_TO_BASKET" => SITE_DIR."personal/cart/",
"PATH_TO_ORDER" => SITE_DIR."personal/order/make/",
"HIDE_ON_BASKET_PAGES" => "N",
"COUNT_DISCOUNT_4_ALL_QUANTITY" => "N",
),
false,
array("HIDE_ICONS" => "Y")
);?>
</div>
Answer the question
In order to leave comments, you need to log in
doka
<?php
// Include Sale module
Bitrix\Main\Loader::includeModule("sale");
// Query: Get all cart items for current user
$res = CSaleBasket::GetList(
array(),
array(
"FUSER_ID" => CSaleBasket::GetBasketUserID(),
"LID" => SITE_ID,
"ORDER_ID" => NULL,
"CAN_BUY" => "Y"
),
false,
false,
array(
"QUANTITY",
"BASE_PRICE",
"PRICE",
"DISCOUNT_PRICE"
)
);
$totalPrice = 0;
// Temp array with cart items
$arItems = array();
// Fetching query
while($arFields = $res->Fetch()){
// Check for base price
if(!isset($arFields['BASE_PRICE']) || (float)$arFields['BASE_PRICE'] <= 0){
$arFields['BASE_PRICE'] = $arFields['PRICE'] + $arFields['DISCOUNT_PRICE'];
}
// Calculate total price without discount
$totalPrice += $arFields["PRICE"] * $arFields["QUANTITY"];
$arItems[] = $arFields;
}
// Make array for discount calculation
$arOrder = array(
'SITE_ID' => SITE_ID,
'ORDER_PRICE' => $totalPrice,
'BASKET_ITEMS' => $arItems
);
// Checking for authorized user
if(is_object($GLOBALS["USER"])){
$arOrder['USER_ID'] = $GLOBALS["USER"]->GetID();
$arErrors = array();
// Calculate discount
CSaleDiscount::DoProcessOrder($arOrder, array(), $arErrors);
}
// All done!
echo $arOrder['ORDER_PRICE'];
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question