Rest API to check user attach to session or not

How to configure and adapt Aimeos based shops as developer
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
traiyani75
Advanced
Posts: 114
Joined: 08 Nov 2019, 11:56

Rest API to check user attach to session or not

Post by traiyani75 » 22 Jan 2020, 04:53

Hello,
How do I get to know that the user is attached with a session token or not via rest API call? Is there any way to do that?

Thanks

User avatar
aimeos
Administrator
Posts: 7893
Joined: 01 Jan 1970, 00:00

Re: Rest API to check user attach to session or not

Post by aimeos » 23 Jan 2020, 10:11

You can use a GET request for the "customer" endpoint. If it returns an empty customer item, the user isn't logged in.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

traiyani75
Advanced
Posts: 114
Joined: 08 Nov 2019, 11:56

Re: Rest API to check user attach to session or not

Post by traiyani75 » 25 Jan 2020, 11:35

Thanks for the help. It works.
Now, I want to get all the orders list which is placed by the user. How do I get all the orders data?

I have tried to use order endpoint, but it returns an only id. How do I get all the values of that order?

User avatar
aimeos
Administrator
Posts: 7893
Joined: 01 Jan 1970, 00:00

Re: Rest API to check user attach to session or not

Post by aimeos » 26 Jan 2020, 16:54

That's still missing while relatively easy to implement:

1.) Use the order/base manager to retrieve the corresponding order/base items here: https://github.com/aimeos/ai-client-jso ... hp#L50-L55

Code: Select all

// $items -> use getBaseId() to get order base ID
$manager = \Aimeos\MShop::create( $context, 'order/base' );
$search = $manager->createSearch()->setSlice( 0, count( $items ) );
$search->setConditions( $search->compare( '==', 'order.base.id', $baseIds ) );
$view->baseItems = $manager->searchItems( $search );
2.) Copy the functions from the basket template to the order template and merge the $entryFcn to with the existing one so it outputs the order and order/base data together:
- https://github.com/aimeos/ai-client-jso ... p#L31-L229
- https://github.com/aimeos/ai-client-jso ... andard.php

3.) Create a pull request at Github with your code :-)
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply