SetShippingMethod
Implements SetShippingMethod
Unified Method.
Source
import { defineApi, getCartVersion } from "@vsf-enterprise/unified-api-commercetools";
import { cartActions } from "@vsf-enterprise/commercetools-api";
import { getNormalizers } from "@vsf-enterprise/unified-api-commercetools/udl";
export const setShippingMethod = defineApi.setShippingMethod(async (context, args) => {
const version = await getCartVersion(context);
const updatedCart = await context.api.updateCart({
...version,
actions: [cartActions.setShippingMethodAction(args.shippingMethodId)],
});
const { normalizeCart } = getNormalizers(context);
return normalizeCart(updatedCart.cart);
});