Search code examples
apispreeproduct

Get products of an order with Spree API


I simply want to get all the orders of my Spree e-commerce system, with all products the user bought in an order. I see I can grab all orders, all shipments, but there is no information about a "complete" query that includes products a user bought.

There is a way to do that ?


Solution

  • GET /api/v1/orders is a paginated query which respons should look something like that:

    {
    "orders": [
      {
        "id": 1,
        "number": "R335381310",
        "item_total": "100.0",
        "display_item_total": "$100.00",
        "total": "100.0",
        "display_total": "$100.00",
        "state": "cart",
        "adjustment_total": "-12.0",
        "user_id": null,
        "created_at": "2012-10-24T01:02:25Z",
        "updated_at": "2012-10-24T01:02:25Z",
        "completed_at": null,
        "payment_total": "0.0",
        "shipment_state": null,
        "payment_state": null,
        "email": null,
        "special_instructions": null,
        "total_quantity": 1,
        "token": "abcdef123456",
        "line_items": [
        ],
        "adjustments": [
        ],
        "payments": [
        ],
        "shipments": [
        ]
      }
    ],
    "count": 25,
    "pages": 5,
    "current_page": 1
    }
    

    Each Order contains line_items, which are products that you are looking for.

    Source: http://guides.spreecommerce.org/api/orders.html