S
S
Sinner32019-05-28 21:31:15
1C-Bitrix
Sinner3, 2019-05-28 21:31:15

How to get all price values ​​in Bitrix?

The site has two types of prices, for authorized and non-authorized users.
it is always necessary to know the values ​​of these prices.
Upon authorization, both types of prices are displayed in the [PRICES] array

Array
(
    [base_price] => Array
        (
            [PRICE_ID] => 1
            [ID] => 2293
            [CAN_ACCESS] => Y
            [CAN_BUY] => Y
            [MIN_PRICE] => N
            [CURRENCY] => RUB
            [VALUE_VAT] => 15
            [VALUE_NOVAT] => 15
            [DISCOUNT_VALUE_VAT] => 15
            [DISCOUNT_VALUE_NOVAT] => 15
            [ROUND_VALUE_VAT] => 15
            [ROUND_VALUE_NOVAT] => 15
            [VALUE] => 15
            [UNROUND_DISCOUNT_VALUE] => 15
            [DISCOUNT_VALUE] => 15
            [DISCOUNT_DIFF] => 0
            [DISCOUNT_DIFF_PERCENT] => 0
            [VATRATE_VALUE] => 0
            [DISCOUNT_VATRATE_VALUE] => 0
            [ROUND_VATRATE_VALUE] => 0
            [PRINT_VALUE_NOVAT] => 15 руб.
            [PRINT_VALUE_VAT] => 15 руб.
            [PRINT_VATRATE_VALUE] => 0 руб.
            [PRINT_DISCOUNT_VALUE_NOVAT] => 15 руб.
            [PRINT_DISCOUNT_VALUE_VAT] => 15 руб.
            [PRINT_DISCOUNT_VATRATE_VALUE] => 0 руб.
            [PRINT_VALUE] => 15 руб.
            [PRINT_DISCOUNT_VALUE] => 15 руб.
            [PRINT_DISCOUNT_DIFF] => 0 руб.
        )

    [web_prise] => Array
        (
            [PRICE_ID] => 3
            [ID] => 12819
            [CAN_ACCESS] => Y
            [CAN_BUY] => Y
            [MIN_PRICE] => Y
            [CURRENCY] => RUB
            [VALUE_VAT] => 14
            [VALUE_NOVAT] => 14
            [DISCOUNT_VALUE_VAT] => 14
            [DISCOUNT_VALUE_NOVAT] => 14
            [ROUND_VALUE_VAT] => 14
            [ROUND_VALUE_NOVAT] => 14
            [VALUE] => 14
            [UNROUND_DISCOUNT_VALUE] => 14
            [DISCOUNT_VALUE] => 14
            [DISCOUNT_DIFF] => 0
            [DISCOUNT_DIFF_PERCENT] => 0
            [VATRATE_VALUE] => 0
            [DISCOUNT_VATRATE_VALUE] => 0
            [ROUND_VATRATE_VALUE] => 0
            [PRINT_VALUE_NOVAT] => 14 руб.
            [PRINT_VALUE_VAT] => 14 руб.
            [PRINT_VATRATE_VALUE] => 0 руб.
            [PRINT_DISCOUNT_VALUE_NOVAT] => 14 руб.
            [PRINT_DISCOUNT_VALUE_VAT] => 14 руб.
            [PRINT_DISCOUNT_VATRATE_VALUE] => 0 руб.
            [PRINT_VALUE] => 14 руб.
            [PRINT_DISCOUNT_VALUE] => 14 руб.
            [PRINT_DISCOUNT_DIFF] => 0 руб.
        )

)

and if the user is not authorized then one
Array
(
    [base_price] => Array
        (
            [PRICE_ID] => 1
            [ID] => 2293
            [CAN_ACCESS] => Y
            [CAN_BUY] => Y
            [MIN_PRICE] => N
            [CURRENCY] => RUB
            [VALUE_VAT] => 15
            [VALUE_NOVAT] => 15
            [DISCOUNT_VALUE_VAT] => 15
            [DISCOUNT_VALUE_NOVAT] => 15
            [ROUND_VALUE_VAT] => 15
            [ROUND_VALUE_NOVAT] => 15
            [VALUE] => 15
            [UNROUND_DISCOUNT_VALUE] => 15
            [DISCOUNT_VALUE] => 15
            [DISCOUNT_DIFF] => 0
            [DISCOUNT_DIFF_PERCENT] => 0
            [VATRATE_VALUE] => 0
            [DISCOUNT_VATRATE_VALUE] => 0
            [ROUND_VATRATE_VALUE] => 0
            [PRINT_VALUE_NOVAT] => 15 руб.
            [PRINT_VALUE_VAT] => 15 руб.
            [PRINT_VATRATE_VALUE] => 0 руб.
            [PRINT_DISCOUNT_VALUE_NOVAT] => 15 руб.
            [PRINT_DISCOUNT_VALUE_VAT] => 15 руб.
            [PRINT_DISCOUNT_VATRATE_VALUE] => 0 руб.
            [PRINT_VALUE] => 15 руб.
            [PRINT_DISCOUNT_VALUE] => 15 руб.
            [PRINT_DISCOUNT_DIFF] => 0 руб.
        ) 
)

web_price for logged
in base_price for those who are not logged
in how do I get the web_price values ​​whether the user is logged in or not?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman Gritsuk, 2019-05-29
@Sinner3

Allow all users to view both price types.
Setting "User groups with rights to view this type of prices"
If this does not help, then the price can also be obtained through the API

<?php

\Bitrix\Main\Loader::includeModule("catalog");

$allProductPrices = \Bitrix\Catalog\PriceTable::getList([
    "filter" => [
        "PRODUCT_ID" => $productId,
    ]
])->fetchAll();

E
Evgeny Nikolaev, 2019-05-29
@nikolaevevge

I will add the CCatalogProduct::GetOptimalPrice() method to the answer above. I don’t remember exactly why it will be useful to me, but the above getList did not manage to get some kind of discount.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question