Page 1 of 1

How to add a customer with an order using JSON API

Posted: 27 Mar 2018, 04:07
by Anshul Dua
How can a user see his/her previous order, I think there is no option to attach a order with any user?
Because When i am saving the basket and creating the order there is no parameter to send the customer id.

Re: How to add a customer with an order using JSON API

Posted: 27 Mar 2018, 07:51
by aimeos
Either the customers have to be logged in or orders are associated depending on their e-mail address.

To retrieve the orders of a customer you have to use the "order" endpoint (GET request without "id" parameter) and the customer has to be logged in.

Re: How to add a customer with an order using JSON API

Posted: 27 Mar 2018, 08:32
by Anshul Dua
I am using the custom login. I made my own API for login. is there any other way with customer id etc?

Re: How to add a customer with an order using JSON API

Posted: 27 Mar 2018, 08:56
by aimeos
It doesn't matter what you use as long as you use the Laravel users table it will work out of the box.

Re: How to add a customer with an order using JSON API

Posted: 27 Mar 2018, 09:00
by Anshul Dua
I am hitting the
http://localhost/jsonapi/order
and getting the response

{
"meta": {
"total": 0,
"prefix": null,
"content-baseurl": "/",
"csrf": {
"name": "_token",
"value": "7AHkga0vq1L6eMqJuixV9XJggdL1JqPLVxyg2hhR"
}
},
"links": {
"self": "http://localhost/jsonapi/order"
},
"data": []
}

but order exist

Re: How to add a customer with an order using JSON API

Posted: 28 Mar 2018, 08:31
by aimeos
Is the "customerid" value in the mshop_order_base table of these orders are same as the users.id value of the user you are logged in with?

Re: How to add a customer with an order using JSON API

Posted: 29 Mar 2018, 05:24
by Anshul Dua
No, It is not. But I made the solution to add the customerid after create the order and Created custom api for order listing.
Thanks