Deferred functions is a technology that allows you to set the page title, navigation chain items, CSS styles, additional buttons in the control panel, meta tags, etc. using the functions used directly in the page body, and output the corresponding results of the work of these functions in the prolog, i.e. output them higher in code than they were given.I found these functions useful when creating an online store, namely to work with a basket. In the store header, in the most visible place hung a basket, it displayed the purchase amount and the quantity of goods. But when you add the product you like to the cart, this inscription has not changed, because the header is formed and displayed earlier than the component is processing the addition of the product to the cart, and then updating its contents. Then I began to look towards LocalRedirect to reload the page after successfully completing the add operation. But those deferred functions helped out. And you can do this here.
<? $APPLICATION->ShowProperty("basket", " "); ?>
if (CModule::IncludeModule("sale")){
$arItems = GetBasketList();
$price = 0;
for ($i = 0; $i<count($arItems); $i++){
$num_prodcts += $arItems[$i]["QUANTITY"];
$price += $arItems[$i]["PRICE"]*$arItems[$i]["QUANTITY"];
}
$res = $num_prodcts.' (.): '.number_format($price, 0, ".", " ").' .
}
else{
$res = " ";
}
$APPLICATION->SetPageProperty("basket", $res);
}
Source: https://habr.com/ru/post/40214/