Retrieve cart item from an order

carts

#1

Hi there !

I would like to retrieve the cart items from an order ID.
Il have some custom fields associated to my cart items that I would like to retrieve once the order has been created.
Do you guys have any recommandations ?

NeilujD


#2

Hey,

You can include items in the call to the products like https://api.moltin.com/v2/orders?include=items

Then if you look in the included field you should see something similar to:

 "items": [
            {
                "type": "order_item",
                "id": "e2da858b-fe9a-4518-8f21-d5afc611315a",
                "quantity": 1,
                "product_id": "5ebb80b1-db82-4144-a9e9-0c8649400ca0",
                "name": "Order Product One",
                "sku": "O.P.12",
                "unit_price": {
                    "amount": 2000,
                    "currency": "GBP",
                    "includes_tax": true
                },

If you need further detail about the product you could then make another call to get the product and pull back its data.

Hope this helps :slight_smile: