index.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?
  2. require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/header.php");
  3. $APPLICATION->SetTitle("Тест");
  4. ?>
  5. <p><?
  6. CModule::IncludeModule('iblock');
  7. \Bitrix\Main\UI\Extension::load("ui.alerts");
  8. $IBLOCK_ID = 4;
  9. define("NOT_CHECK_PERMISSIONS", true);
  10. $arBask = json_decode($_COOKIE['basket']);
  11. $arBasket = array();
  12. foreach ($arBask as $object) {
  13. array_push($arBasket, $object->id);
  14. }
  15. $arBasketFilter = ["ID" => $arBasket];
  16. $arFilter = Array("IBLOCK_ID"=>4, "ID"=>$arBasket);?>
  17. <?$arSelect = Array("ID", "IBLOCK_ID", "NAME", "DATE_ACTIVE_FROM","PROPERTY_*");//IBLOCK_ID и ID обязательно должны быть указаны, см. описание arSelectFields выше
  18. $res = CIBlockElement::GetList(Array(), $arFilter, false, Array("nPageSize"=>50), $arSelect);
  19. $wth_discount = 0;
  20. $sum = 0;
  21. while($ob = $res->GetNextElement()){
  22. $arFields = $ob->GetFields();
  23. $arProps = $ob->GetProperties();
  24. if ($arProps["DISCOUNT"]["VALUE"]){
  25. $new_price = $arProps["PRICE"]["VALUE"] - ($arProps["PRICE"]["VALUE"] * $arProps["DISCOUNT"]["VALUE"] / 100);
  26. $wth_discount+=$new_price;
  27. }
  28. else{
  29. $wth_discount+=$arProps["PRICE"]["VALUE"];
  30. }
  31. $sum+=$arProps["PRICE"]["VALUE"];
  32. }?>
  33. <h3><?=$sum;?> <?=$wth_discount;?></h3>
  34. <? require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/footer.php"); ?>