Skip to main content

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

ParameterTypeDescription
attributesObjectBlock attributes containing the order node at attributes.blockItem.node.
onActionFunctionAction handler for navigation.

Return Value

PropertyTypeDescription
orderIdstringOrder name/number (without # prefix).
orderObjectThe full order node object.
orderDatestringFormatted order date (e.g., "Feb 13th 26").
statusstringOrder fulfillment status.
paymentMethodstringOrder financial status.
lineItemsArrayArray of order line item nodes.
numberOfItemsnumberTotal number of line items in the order.
totalPricestringTotal price amount.
orderTotalAmountWithCurrencystringFormatted total price with currency symbol.
totalShippingPriceObjectShipping price object.
subtotalPriceObjectSubtotal price object.
totalTaxObjectTotal tax object.
emailstringCustomer email.
billingAddressObjectBilling address object.
shippingAddressObjectShipping address object.
addressNamestringFormatted shipping address name (first + last).
address1stringShipping address line 1.
address2stringShipping address line 2.
citystringShipping city.
countrystringShipping country.
zipstringShipping zip code.
phonestringShipping phone number.
orderFulfillmentArraySuccessful fulfillment objects.
hideOrderFulfillmentbooleanWhether to hide fulfillment status (from plugin settings).
openOrderDetailFunctionNavigates to order detail page. Accepts optional { openById: boolean }.
withCurrencyFunctionCurrency formatting helper. Signature: withCurrency(amount, currencyCode).