Fix error before M7

This commit is contained in:
Nông Đức Huy
2026-08-13 23:20:23 +07:00
parent 624a6402bf
commit 1e356a2578
11 changed files with 331 additions and 14 deletions
+16 -3
View File
@@ -54,7 +54,17 @@ export interface CommerceResource {
removeCartLine(locale: Locale, variantId: string, options?: RequestOptions): Promise<Cart>;
getCheckoutQuote(locale: Locale, options?: RequestOptions): Promise<Cart>;
placeOrder(locale: Locale, input: PlaceOrderInput, options?: RequestOptions): Promise<Order>;
/**
* `idempotencyKey` must be stable across retries of the *same* attempt and
* different between attempts — the server uses it to tell a resend apart from
* a second purchase.
*/
placeOrder(
locale: Locale,
idempotencyKey: string,
input: PlaceOrderInput,
options?: RequestOptions,
): Promise<Order>;
lookupOrder(orderNumber: string, email: string, options?: RequestOptions): Promise<Order>;
getPlacedOrder(id: string, options?: RequestOptions): Promise<Order>;
}
@@ -112,8 +122,11 @@ export function createCommerceResource(http: HttpClient): CommerceResource {
getCheckoutQuote: (locale, options) =>
http.get<Cart>('/checkout/quote', cartOptions(locale, options)),
placeOrder: (locale, input, options) =>
http.post<Order>('/checkout/orders', input, cartOptions(locale, options)),
placeOrder: (locale, idempotencyKey, input, options) =>
http.post<Order>('/checkout/orders', input, {
...cartOptions(locale, options),
headers: { 'Idempotency-Key': idempotencyKey, ...options?.headers },
}),
getPlacedOrder: (id, options) =>
http.get<Order>(`/checkout/orders/${encodeURIComponent(id)}`, {