G
G
Goldsliders2021-09-28 15:39:56
1C-Bitrix
Goldsliders, 2021-09-28 15:39:56

How to display the number of paid orders?

It is necessary for each user to display the number of paid orders (not the orders themselves, but only the total number). How can you do?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Kirill Novozhilov, 2021-09-28
@Goldsliders

Use the new kernel :)

Bitrix\Main\Loader::includeModule('sale');

$orders = Bitrix\Sale\OrderTable::getList([
    'filter' => [
        'PAYED' => 'Y'
    ],
    'group' => ['USER_ID'],
    'select' => ['USER_ID', 'CNT'],
    'runtime' => [
        new Bitrix\Main\Entity\ExpressionField('CNT', 'COUNT(*)')
    ]
])->fetchAll();

A
Alams Stoyne, 2021-09-28
@alams_stoyne

$arFilter = array("USER_ID" => $USER->GetID(), 'PAYED' => 'Y');
$rsOrders = CSaleOrder::GetList(array('ID' => 'DESC'), $arFilter, array('PAYED', 'SUM' => 'PRICE'));
$arOrder = $rsOrder->Fetch();
echo $arOrder['CNT'];

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question