Przejdź do głównej zawartości

Function: recreateWithInput()

recreateWithInput(input): (cartClient) => Promise<{ cart: CartFragment; result: CartMutationOutcome; secret: string | null; }>

Build a recreateAndRun for any operation expressible as a single cartCreate(input) call. The fresh cart's outcome ({ cart, warnings }) is returned as result, matching what the equivalent post-create write would have returned — caller code stays uniform between happy and recovery paths.

Use for: addItems (lines), updateBuyerIdentity (buyerIdentity), setShippingAddress (shippingAddress), updateDiscountCodes (discountCodes), updateNote (note), or any combination.

Parameters

input

CartCreateInput

Returns

(cartClient) => Promise<{ cart: CartFragment; result: CartMutationOutcome; secret: string | null; }>

Example

const operation: CartRecoveryOperation<CartMutationOutcome> = {
run: (cartId) => cartClient.addItems(cartId, lines),
recreateAndRun: recreateWithInput({ lines }),
name: 'addItems',
};