J
J
Jupiter Max2018-12-27 13:47:13
1C-Bitrix
Jupiter Max, 2018-12-27 13:47:13

How to withdraw the amount taking into account the Bitrix discount?

Guys, urgently need help. I display the goods I need through getlist. In the admin area, discounts are applied for these products. Regular prices are displayed now. How can I display already discounted prices in cards? I can not understand.
the code itself

<?
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/header.php");
$APPLICATION->SetTitle("Каталог товаров");
?>

<div class="cat-tork"><?
$arSelect = Array("*", "CATALOG_GROUP_24", "PROPERTY_CML2_ARTICLE");
if ( CSite::InGroup( array(12,13,14) ) ) {
  $arFilter = Array("IBLOCK_ID"=>59, "IBLOCK_TYPE" => "1c_catalog", "ID"=>array(121990, 124159,133627,132686,124163,133612,126599,137535,121988,123239,121978), "ACTIVE"=>"Y");
}
if ( CSite::InGroup( array(15) ) ) {
  $arFilter = Array("IBLOCK_ID"=>59, "IBLOCK_TYPE" => "1c_catalog", "ID"=>array(121990, 126599, 121988, 123239, 133627, 124159, 124163, 121978,127680), "ACTIVE"=>"Y");
}

$res = CIBlockElement::GetList(Array(), $arFilter, false, false, $arSelect);
while($ob = $res->GetNextElement())
{
  
  $arFields = $ob->GetFields();
  $PREVIEW_PICTURE = CFile::GetPath($arFields["PREVIEW_PICTURE"]);
  //echo "<pre>"; print_r($ob); echo "</pre>";
  //echo "<pre>"; print_r($PREVIEW_PICTURE); echo "</pre>";
  ?>
  <div class="cat-element">
    <div class="cat-img-prev">
      <img src="<?=$PREVIEW_PICTURE; ?>" alt="" />
    </div>
    <div class="cat-name">
      <?=$arFields["NAME"];?>
    </div>
    <div class="cat-articul">
      <b>Артикул: </b> <?=$arFields["PROPERTY_CML2_ARTICLE_VALUE"];?>
    </div>
    <div class="cat-price">
      <? echo $arFields["CATALOG_PRICE_24"];?> руб.
    </div>
    <form action="" method="post" class="add-bsk">
      <input type="hidden" name="productname" value="<?=$arFields["NAME"]?>" />
      <input type="hidden" name="productprice" value="<?=$arFields["CATALOG_PRICE_24"]?>" />
      <input type="hidden" name="productid" value="<?=$arFields["ID"]?>" />
      <button type="submit" class="add-bsk single-button">В корзину</button>
    </form>
  </div>
  <?
}
?></div>

<?require($_SERVER["DOCUMENT_ROOT"]."/bitrix/footer.php");?>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ilya, 2018-12-27
@vardoLP

// это цена
$dbPrice = \CPrice::GetList(
  array(),
  array(
    "PRODUCT_ID" => $PRODUCT_ID,
    "CATALOG_GROUP_ID" => $PERSON_TYPE_ID
  )
);
$arPrice = $dbPrice->Fetch();
$price = $arPrice["PRICE"];

// это список доступных скидок
$arDiscounts = \CCatalogDiscount::GetDiscountByProduct(
    $PRODUCT_ID,
    $USER->GetUserGroupArray(),
    "N",
    $PERSON_TYPE_ID,
    SITE_ID
);
if($arDiscounts !== false) {
  $price = \CCatalogProduct::CountPriceWithDiscount(
      $arPrice["PRICE"],
      $arPrice["CURRENCY"],
      $arDiscounts
  );
}

// в переменной $price будет цена с учетом скидок

M
Mikhail Deynekin, 2020-07-07
@paulmann

This code works for simple discount calculation rules. How to modify it for product discounts that are calculated based on the combination of products in the cart?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question