Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exposes order-confirmation api and adds confirmationNumber to order #1682

Merged
merged 3 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/smart-vans-serve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/ui-extensions': minor
---

Exposes order-confirmation api and adds confirmationNumber to order
thitemple marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 4 additions & 0 deletions packages/ui-extensions/src/surfaces/checkout/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ export type {
CheckoutApi,
} from './api/checkout/checkout';
export type {Order, OrderStatusApi} from './api/order-status/order-status';
export type {
OrderConfirmation,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the checkout-web PR, this export is missing OrderConfirmation. I assume this should be exported? Not a blocker for this PR, but ican do a follow-up PR in checkout-web to keep these in-sync?

For context, there is a script that will actually move these files over to ui-extensions so that they are always the same. In this case we are manually applying the same changes, so they need to be exact otherwise the next script run will overwrite this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can create a quick PR on checkout-web to do that

OrderConfirmationApi,
} from './api/order-confirmation/order-confirmation';

export type {CartLineItemApi} from './api/cart-line/cart-line-item';
export type {PickupLocationListApi} from './api/pickup/pickup-location-list';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import type {StatefulRemoteSubscribable} from '@remote-ui/async-subscription';

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;
thitemple marked this conversation as resolved.
Show resolved Hide resolved
}

export interface OrderConfirmationApi {
/**
* Order information that's available post-checkout.
*/
orderConfirmation: StatefulRemoteSubscribable<OrderConfirmation>;
}
47 changes: 31 additions & 16 deletions packages/ui-extensions/src/surfaces/checkout/targets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import type {
ShippingOptionListApi,
} from './api';
import type {AnyComponent} from './shared';
import {OrderConfirmationApi} from './api/order-confirmation/order-confirmation';
thitemple marked this conversation as resolved.
Show resolved Hide resolved

/**
* A UI extension will register for one or more extension targets using `shopify.extend()`.
Expand Down Expand Up @@ -192,7 +193,7 @@ export interface ExtensionTargets {
*
*/
'purchase.thank-you.block.render': RenderExtension<
StandardApi<'purchase.thank-you.block.render'>,
OrderConfirmationApi & StandardApi<'purchase.thank-you.block.render'>,
AnyComponent
>;
/**
Expand All @@ -206,15 +207,16 @@ export interface ExtensionTargets {
* @deprecated Use `purchase.thank-you.block.render` instead.
*/
'Checkout::ThankYou::Dynamic::Render': RenderExtension<
StandardApi<'Checkout::ThankYou::Dynamic::Render'>,
OrderConfirmationApi & StandardApi<'Checkout::ThankYou::Dynamic::Render'>,
AnyComponent
>;
/**
* A static extension target that renders on every line item, inside the details
* under the line item properties element on the **Thank you** page.
*/
'purchase.thank-you.cart-line-item.render-after': RenderExtension<
CartLineItemApi &
OrderConfirmationApi &
CartLineItemApi &
StandardApi<'purchase.thank-you.cart-line-item.render-after'>,
AnyComponent
>;
Expand All @@ -225,15 +227,17 @@ export interface ExtensionTargets {
* @deprecated Use `purchase.thank-you.cart-line-item.render-after` instead.
*/
'Checkout::ThankYou::CartLineDetails::RenderAfter': RenderExtension<
CartLineItemApi &
OrderConfirmationApi &
CartLineItemApi &
StandardApi<'Checkout::ThankYou::CartLineDetails::RenderAfter'>,
AnyComponent
>;
/**
* A static extension target that is rendered after all line items on the **Thank you** page.
*/
'purchase.thank-you.cart-line-list.render-after': RenderExtension<
StandardApi<'purchase.thank-you.cart-line-list.render-after'>,
OrderConfirmationApi &
StandardApi<'purchase.thank-you.cart-line-list.render-after'>,
AnyComponent
>;
/**
Expand All @@ -242,14 +246,16 @@ export interface ExtensionTargets {
* @deprecated Use `purchase.thank-you.cart-line-list.render-after` instead.
*/
'Checkout::ThankYou::CartLines::RenderAfter': RenderExtension<
StandardApi<'Checkout::ThankYou::CartLines::RenderAfter'>,
OrderConfirmationApi &
StandardApi<'Checkout::ThankYou::CartLines::RenderAfter'>,
AnyComponent
>;
/**
* A static extension target that is rendered after a purchase below the customer information on the **Thank you** page.
*/
'purchase.thank-you.customer-information.render-after': RenderExtension<
StandardApi<'purchase.thank-you.customer-information.render-after'>,
OrderConfirmationApi &
StandardApi<'purchase.thank-you.customer-information.render-after'>,
AnyComponent
>;
/**
Expand All @@ -258,7 +264,8 @@ export interface ExtensionTargets {
* @deprecated Use `purchase.thank-you.customer-information.render-after` instead.
*/
'Checkout::ThankYou::CustomerInformation::RenderAfter': RenderExtension<
StandardApi<'Checkout::ThankYou::CustomerInformation::RenderAfter'>,
OrderConfirmationApi &
StandardApi<'Checkout::ThankYou::CustomerInformation::RenderAfter'>,
AnyComponent
>;
/**
Expand All @@ -272,7 +279,8 @@ export interface ExtensionTargets {
* @deprecated Use `customer-account.order-status.block.render` from `@shopify/ui-extension/customer-account` instead.
*/
'customer-account.order-status.block.render': RenderExtension<
OrderStatusApi &
OrderConfirmationApi &
OrderStatusApi &
CustomerAccountStandardApi<'customer-account.order-status.block.render'>,
AnyComponent
>;
Expand All @@ -287,7 +295,8 @@ export interface ExtensionTargets {
* @deprecated Use `customer-account.order-status.block.render` from `@shopify/ui-extension/customer-account` instead.
*/
'Checkout::OrderStatus::Dynamic::Render': RenderExtension<
OrderStatusApi &
OrderConfirmationApi &
OrderStatusApi &
CustomerAccountStandardApi<'Checkout::OrderStatus::Dynamic::Render'>,
AnyComponent
>;
Expand All @@ -298,7 +307,8 @@ export interface ExtensionTargets {
* @deprecated Use `customer-account.order-status.cart-line-item.render-after` from `@shopify/ui-extension/customer-account` instead.
*/
'customer-account.order-status.cart-line-item.render-after': RenderExtension<
CartLineItemApi &
OrderConfirmationApi &
CartLineItemApi &
OrderStatusApi &
CustomerAccountStandardApi<'customer-account.order-status.cart-line-item.render-after'>,
AnyComponent
Expand All @@ -310,7 +320,8 @@ export interface ExtensionTargets {
* @deprecated Use `customer-account.order-status.cart-line-item.render-after` instead.
*/
'Checkout::OrderStatus::CartLineDetails::RenderAfter': RenderExtension<
CartLineItemApi &
OrderConfirmationApi &
CartLineItemApi &
OrderStatusApi &
CustomerAccountStandardApi<'Checkout::OrderStatus::CartLineDetails::RenderAfter'>,
AnyComponent
Expand All @@ -321,7 +332,8 @@ export interface ExtensionTargets {
* @deprecated Use `customer-account.order-status.cart-line-list.render-after` from `@shopify/ui-extension/customer-account` instead.
*/
'customer-account.order-status.cart-line-list.render-after': RenderExtension<
OrderStatusApi &
OrderConfirmationApi &
OrderStatusApi &
CustomerAccountStandardApi<'customer-account.order-status.cart-line-list.render-after'>,
AnyComponent
>;
Expand All @@ -331,7 +343,8 @@ export interface ExtensionTargets {
* @deprecated Use `customer-account.order-status.cart-line-list.render-after` from `@shopify/ui-extension/customer-account` instead.
*/
'Checkout::OrderStatus::CartLines::RenderAfter': RenderExtension<
OrderStatusApi &
OrderConfirmationApi &
OrderStatusApi &
CustomerAccountStandardApi<'Checkout::OrderStatus::CartLines::RenderAfter'>,
AnyComponent
>;
Expand All @@ -341,7 +354,8 @@ export interface ExtensionTargets {
* @deprecated Use `customer-account.order-status.customer-information.render-after` from `@shopify/ui-extension/customer-account` instead.
*/
'customer-account.order-status.customer-information.render-after': RenderExtension<
OrderStatusApi &
OrderConfirmationApi &
OrderStatusApi &
CustomerAccountStandardApi<'customer-account.order-status.customer-information.render-after'>,
AnyComponent
>;
Expand All @@ -351,7 +365,8 @@ export interface ExtensionTargets {
* @deprecated Use `customer-account.order-status.customer-information.render-after` from `@shopify/ui-extension/customer-account` instead.
*/
'Checkout::OrderStatus::CustomerInformation::RenderAfter': RenderExtension<
OrderStatusApi &
OrderConfirmationApi &
OrderStatusApi &
CustomerAccountStandardApi<'Checkout::OrderStatus::CustomerInformation::RenderAfter'>,
AnyComponent
>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1194,4 +1194,9 @@ export interface Order {
* If cancelled, the time at which the order was cancelled.
*/
cancelledAt?: string;
/**
* A randomly generated alpha-numeric identifier for the order.
* This number should always be present, but 2023 orders predate confirmation numbers and may not have it.
thitemple marked this conversation as resolved.
Show resolved Hide resolved
*/
confirmationNumber?: string;
}
Loading