PlaceOrder
Implements PlaceOrder
Unified Method.
Source
import { defineApi } from "@vsf-enterprise/unified-api-sfcc";
import { getNormalizers } from "@vsf-enterprise/unified-api-sfcc/udl";
declare module "@vsf-enterprise/unified-api-sfcc" {
interface PlaceOrderExtendedArgs {}
}
export const placeOrder = defineApi.placeOrder(async (context) => {
const cart = await context.api.getBasket();
if (!cart.basketId) {
throw new Error("Cart is empty");
}
const order = await context.api.createOrder({ basketId: cart.basketId });
const { normalizeOrder } = getNormalizers(context);
return normalizeOrder(order);
});