Parameters
| Param | Type | Required | Default | Description |
|---|---|---|---|---|
limit | number | No | 10 | Maximum orders to return |
Returns
Throws
Error- If not logged in.
Get customer order history
shoppy.customer.orders(limit?)
| Param | Type | Required | Default | Description |
|---|---|---|---|---|
limit | number | No | 10 | Maximum orders to return |
Promise<{
orders: ShopifyOrder[]
pageInfo: ShopifyPageInfo
}>
Error - If not logged in.const { orders } = await shoppy.customer.orders()
orders.forEach(order => {
console.log(`Order ${order.name}: ${order.totalPrice.amount}`)
})
async function loadOrderHistory() {
const { orders } = await shoppy.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>
`
})
}
const { orders } = await shoppy.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}`)
}
})
})
{
id: string
orderNumber: number
name: string // "#1001"
processedAt: string // ISO date
financialStatus: string
fulfillmentStatus: string
totalPrice: ShopifyMoney
subtotalPrice: ShopifyMoney
totalShippingPrice: ShopifyMoney
totalTax: ShopifyMoney
currencyCode: string
statusUrl: string // Link to order status page
lineItems: Connection<ShopifyOrderLineItem>
shippingAddress: ShopifyCustomerAddress
}