OrderAPI
API
The API for interacting with the order confirmation, available on the Thank You page.
Anchor to orderconfirmationapiOrderConfirmationApi
The API object provided to purchase.thank-you
extension targets.
- Anchor to orderConfirmationorderConfirmationStatefulRemoteSubscribable<>required
Order information that's available post-checkout.
OrderConfirmationApi
- orderConfirmation
Order information that's available post-checkout.
StatefulRemoteSubscribable<OrderConfirmation>
export interface OrderConfirmationApi {
/**
* Order information that's available post-checkout.
*/
orderConfirmation: StatefulRemoteSubscribable<OrderConfirmation>;
}
OrderConfirmation
- isFirstOrder
Whether this is the customer's first order.
boolean
- number
A randomly generated alpha-numeric identifier for the order. For orders created in 2024 and onwards, the number will always be present. For orders created before that date, the number might not be present.
string
- order
{ id: string; }
export interface OrderConfirmation {
order: {
/**
* The globally-uniqueID of the OrderConfirmation. This will be the ID of the Order once successfully created.
*/
id: string;
};
/**
* A randomly generated alpha-numeric identifier for the order.
* For orders created in 2024 and onwards, the number will always be present. For orders created before that date, the number might not be present.
*/
number?: string;
/**
* Whether this is the customer's first order.
*/
isFirstOrder: boolean;
}
Was this section helpful?
Order confirmation
import {
reactExtension,
Banner,
useApi,
useSubscription,
} from '@shopify/ui-extensions-react/checkout';
export default reactExtension(
'purchase.thank-you.block.render',
() => <Extension />,
);
function Extension() {
const {orderConfirmation} = useApi();
const {id} = useSubscription(orderConfirmation);
if (id) {
return (
<Banner>
Please include your order confirmation ID
({id}) in support requests
</Banner>
);
}
return null;
}
examples
Order confirmation
React
import { reactExtension, Banner, useApi, useSubscription, } from '@shopify/ui-extensions-react/checkout'; export default reactExtension( 'purchase.thank-you.block.render', () => <Extension />, ); function Extension() { const {orderConfirmation} = useApi(); const {id} = useSubscription(orderConfirmation); if (id) { return ( <Banner> Please include your order confirmation ID ({id}) in support requests </Banner> ); } return null; }
JavaScript
import { Banner, extension, } from '@shopify/ui-extensions/checkout'; export default extension( 'purchase.thank-you.block.render', (root, {orderConfirmation}) => { let bannerShown = false; orderConfirmation.subscribe( (orderConfirmation) => { if (orderConfirmation && !bannerShown) { root.appendChild( root.createComponent( Banner, undefined, `Please include your order confirmation ID (${orderConfirmation.id}) in support requests`, ), ); bannerShown = true; } }, ); }, );