The Vue Storefront Essentials Course is now available! Learn More
Cart normalizer

Cart normalizer

The normalizeCart function is used to map a SFCC Basket into the unified SfCart data model.


NameTypeDefault valueDescription
basketBasketSFCC Cart
ctxNormalizerContextContext needed for the normalizer. Context contain a currency field that contains a currency code


The SfCart structure is returned from all Unified Cart Methods such as GetCart, AddCartLineItem, and UpdateCartLineItem. If the SfCart structure doesn't contain the information you need for your Storefront, you can extend its logic using the defineNormalizers function. The following example demonstrates how to extend SfCart with an lastModification field.

import { normalizers as normalizersSFCC, defineNormalizers } from "@vsf-enterprise/unified-api-sfcc";

const normalizers = defineNormalizers<typeof normalizersSFCC>()({
  normalizeCart: (basket, context) => ({
    ...normalizersSFCC.normalizeCart(basket, context),
    lastModification: basket.lastModified,


The normalizeCart function consists of several smaller normalizers such as normalizeCartCoupon, normalizeShippingMethod, and more. If you decide to override the normalization function, you should only override the root normalizer, which is normalizeCart.

šŸ”“ ../../node_modules/@vsf-enterprise/unified-api-sfcc/src/normalizers/cart/cart.ts | Snippet does not exist šŸ”“ šŸ”“ ../../node_modules/@vsf-enterprise/unified-api-sfcc/src/normalizers/cart/cartCoupon.ts | Snippet does not exist šŸ”“ šŸ”“ ../../node_modules/@vsf-enterprise/unified-api-sfcc/src/normalizers/cart/shippingMethod.ts | Snippet does not exist šŸ”“ šŸ”“ ../../node_modules/@vsf-enterprise/unified-api-sfcc/src/normalizers/cart/lineItem.ts | Snippet does not exist šŸ”“