Answer the question
In order to leave comments, you need to log in
How to display a list of users who have items in their cart?
What I do:
Get a list of
users I need by their ID
Get a list of products in the basket of selected users through FUSER_ID
What you need:
Let's just say, you need to build such a layout. There are lines with user data. Clicking on each opens a list with the products that he currently has in his cart.
Question
How to connect the obtained values and build the layout described above.
Answer the question
In order to leave comments, you need to log in
1) If you have Bitrix in the Business edition, then there is no need to reinvent the wheel. This page already exists in the admin panel. Shop -> Customers -> Baskets.
2) If, nevertheless, this is a small business editorial or you need to display all this in public, then:
List of buyers:
$users = \Bitrix\Sale\Internals\BasketTable::getList([
"select" => [
"USER_ID" => "FUSER.USER.ID",
"USER_EMAIL" => "FUSER.USER.EMAIL",
],
"filter" => [
"!FUSER.USER_ID" => NULL,
"ORDER_ID" => NULL,
],
"group" => [
"FUSER.USER.ID",
"FUSER.USER.EMAIL"
]
])->fetchAll();
$users = \Bitrix\Sale\Internals\BasketTable::getList([
"select" => [
"FUSER_ID",
"USER_ID" => "FUSER.USER.ID",
"USER_EMAIL" => "FUSER.USER.EMAIL",
],
"filter" => [
"ORDER_ID" => NULL,
],
"group" => [
"FUSER_ID",
"FUSER.USER.ID",
"FUSER.USER.EMAIL"
]
])->fetchAll();
$fuserId = 44514;//ID покупателя !!!!! НЕ пользователя
$basket = \Bitrix\Sale\Internals\BasketTable::getList([
"select" => [
"*"
],
"filter" => [
"FUSER_ID" => $fuserId,
"ORDER_ID" => NULL,
],
])->fetchAll();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question