M
M
Maxim Morozov2020-06-04 13:09:52
1C-Bitrix
Maxim Morozov, 2020-06-04 13:09:52

How to display the price (by id or price type code) in the element template in 1s-Bitrix?

Please tell me how you can display the price (of a certain type of prices id: "18", type code: "MIN") in the template, as an additional one, I will display it only for a certain group of users using:

<?php global $USER;
$dop_price = "доп цена";
$groupID = 11;
if (in_array($groupID,$USER->GetUserGroupArray())){
  echo "$dop_price";
}?>

Tried to use:
$db_res = CPrice::GetList(
        array(),
        array(
                "PRODUCT_ID" => $PRODUCT_ID,
                "CATALOG_GROUP_ID" => "MIN"
            )
    );
if ($ar_res = $db_res->Fetch())
{
    echo CurrencyFormat($ar_res["PRICE"], $ar_res["CURRENCY"]);
}
else
{
    echo "Цена не найдена!";
}
?>

But the experience with php is apparently very small and nothing comes out ...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Morozov, 2020-06-04
@morozoffmaks

Figured it out myself:

// Выведем цену типа $PRICE_TYPE_ID товара с кодом $PRODUCT_ID
$PRICE_TYPE_ID = '18'; // ID Типа цен
$db_res = CPrice::GetList(
        array(),
        array(
                "PRODUCT_ID" => $arResult['ID'],  // Получаем ID Товара
                "CATALOG_GROUP_ID" => $PRICE_TYPE_ID // Получаем ID типа цен из переменной
            )
    );
if ($ar_res = $db_res->Fetch())
{
    echo CurrencyFormat($ar_res["PRICE"], $ar_res["CURRENCY"]); // Выводим цену
}
else
{
    echo "Цена не найдена!"; // Выводим (если нет цены)
}
?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question