useOrderItem
This hook extracts and formats order data from block attributes for rendering order items in the order list. It provides order details, shipping address, pricing, and a function to navigate to the order detail page.
Import
import { useOrderItem } from '@appmaker-xyz/shopify';
Basic Usage
const {
orderId,
order,
orderDate,
status,
lineItems,
orderTotalAmountWithCurrency,
openOrderDetail,
} = useOrderItem({ attributes, onAction });
Parameters
| Parameter | Type | Description |
|---|---|---|
attributes | Object | Block attributes containing the order node at attributes.blockItem.node. |
onAction | Function | Action handler for navigation. |
Return Value
| Property | Type | Description |
|---|---|---|
orderId | string | Order name/number (without # prefix). |
order | Object | The full order node object. |
orderDate | string | Formatted order date (e.g., "Feb 13th 26"). |
status | string | Order fulfillment status. |
paymentMethod | string | Order financial status. |
lineItems | Array | Array of order line item nodes. |
numberOfItems | number | Total number of line items in the order. |
totalPrice | string | Total price amount. |
orderTotalAmountWithCurrency | string | Formatted total price with currency symbol. |
totalShippingPrice | Object | Shipping price object. |
subtotalPrice | Object | Subtotal price object. |
totalTax | Object | Total tax object. |
email | string | Customer email. |
billingAddress | Object | Billing address object. |
shippingAddress | Object | Shipping address object. |
addressName | string | Formatted shipping address name (first + last). |
address1 | string | Shipping address line 1. |
address2 | string | Shipping address line 2. |
city | string | Shipping city. |
country | string | Shipping country. |
zip | string | Shipping zip code. |
phone | string | Shipping phone number. |
orderFulfillment | Array | Successful fulfillment objects. |
hideOrderFulfillment | boolean | Whether to hide fulfillment status (from plugin settings). |
openOrderDetail | Function | Navigates to order detail page. Accepts optional { openById: boolean }. |
withCurrency | Function | Currency formatting helper. Signature: withCurrency(amount, currencyCode). |