A
A
Andrey Bely2020-08-06 19:34:39
1C-Bitrix
Andrey Bely, 2020-08-06 19:34:39

How to check if a user placed orders in the Bitrix online store?

Good evening.
The customer wants feedback to be able to leave a user who:
1. Logged in;
2. Made an order;
3. Feedback can only be left for the ordered product;
Accordingly, I want to make a check for the button "Write a review" . With authorization, everything is clear $GLOBALS['USER']->IsAuthorized(), but what about the rest? Through which class can you check information about the presence of already formed orders in the user, or if there is a more rational way to solve the problem?
5f2c2f2d4f7a0169872479.png
Good evening everyone! :)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
PetrPo, 2020-08-06
@just_guy95

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

global $USER;

$userId = $USER->GetID();
$productId = 45;

$order = \Bitrix\Sale\Order::getList([
    'select' => ['ID'],
    'filter' => ['USER_ID' => $userId, 'BASKET.PRODUCT_ID' => $productId],
    'limit' => 1
])->fetch();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question