3

I want all orders of customer using customer's Token in Magento API.

Which gives the list of all previous orders of the customer.

This API provides me the cart products of specific customer using customer's Token.

http://<magento-host>/rest/V1/carts/mine

Authorization :: Bearer <Customer Token>

Thanks in advance!

  • Can you please elaborate how did you achieved it? – Bhargava Rama Sep 27 '18 at 14:21
  • Yes of-cause, can you please ask the question for the same ? – Aditya Shah Sep 27 '18 at 15:13
4

You should be able to filter out the orders of a single customer using the search query parameters like this:

https://<mage host>/rest/V1/orders/?searchCriteria[filterGroups][0][filters]
[0][field]=customer_id&searchCriteria[filterGroups][0][filters][0][value]=<customer_id>

This returns a list of orders on which you can loop and find out other information.

2

I think Magento2 doesn't provide inbuilt functionality for customer token to fetch all orders so you need to implement the same.

And for that, kindly refer below link

https://magento.stackexchange.com/questions/167749/get-pending-completed-processing-orders-rest-api-problem

http://www.ipragmatech.com/extend-magento2-rest-api-easy-steps/
2

Got the solution For this!!

Magento is using resource Magento_Sales::sales because of this we can't access it using Customer's token so for the same we need to override Specific API with

<resource ref="self" />

And using this we can access all orders of specific customer using customer's Token in Magento API.

<route url="/V1/orders" method="GET">
        <service class="Magento\Sales\Api\OrderRepositoryInterface" method="getList"/>
        <resources>
            <resource ref="self" />
        </resources>
    </route>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.