> ## Documentation Index
> Fetch the complete documentation index at: https://docs.openbridge.shop/llms.txt
> Use this file to discover all available pages before exploring further.

# .orders()

> Get customer order history

```javascript theme={null}
openbridge.customer.orders(limit?)
```

Fetches the customer's order history from Shopify, sorted by most recent first.

## Parameters

| Param   | Type     | Required | Default | Description              |
| ------- | -------- | -------- | ------- | ------------------------ |
| `limit` | `number` | No       | `10`    | Maximum orders to return |

## Returns

```typescript theme={null}
Promise<{
    orders: ShopifyOrder[]
    pageInfo: ShopifyPageInfo
}>
```

## Throws

* `Error` - If not logged in.

## Examples

### Get recent orders

```javascript theme={null}
const { orders } = await openbridge.customer.orders()

orders.forEach(order => {
    console.log(`Order ${order.name}: ${order.totalPrice.amount}`)
})
```

### Display order history

```javascript theme={null}
async function loadOrderHistory() {
    const { orders } = await openbridge.customer.orders(20)

    const container = document.querySelector('#orders')

    orders.forEach(order => {
        container.innerHTML += `
            <div class="order">
                <h3>${order.name}</h3>
                <p>Date: ${new Date(order.processedAt).toLocaleDateString()}</p>
                <p>Status: ${order.fulfillmentStatus}</p>
                <p>Total: ${order.totalPrice.amount} ${order.totalPrice.currencyCode}</p>
                <a href="${order.statusUrl}">View Details</a>
            </div>
        `
    })
}
```

### Order with line items

```javascript theme={null}
const { orders } = await openbridge.customer.orders(5)

orders.forEach(order => {
    console.log(`\nOrder ${order.name}:`)

    order.lineItems.edges.forEach(({ node: item }) => {
        console.log(`  - ${item.title} x${item.quantity}`)
        if (item.variant) {
            console.log(`    ${item.variant.price.amount}`)
        }
    })
})
```

## ShopifyOrder Structure

```typescript theme={null}
{
    id: string
    orderNumber: number
    name: string                                  // "#1001"
    processedAt: string                           // ISO date
    financialStatus: string | null
    fulfillmentStatus: string
    totalPrice: ShopifyMoney
    subtotalPrice: ShopifyMoney | null
    totalShippingPrice: ShopifyMoney
    totalTax: ShopifyMoney | null
    currencyCode: string
    statusUrl: string                             // Link to order status page
    lineItems: ShopifyConnection<ShopifyOrderLineItem>
    shippingAddress: ShopifyCustomerAddress | null
}
```

See [ShopifyOrder](/api/types/customer#shopifyorder) for the full type reference.
