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

Order normalizer

  • normalizeOrder: This function is used to map SFCC Order into SfOrder, which includes order details data.
  • normalizeOrderListItem: This function maps SFCC ProductItem into SfOrderListItem which includes only basic order details, used to display an data in an order list.

Parameters

normalizeOrder

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

normalizeOrderListItem

NameTypeDefault valueDescription
inputProductItemSFCC Order List Element

Extending

The SfOrder is returned from the GetOrders Method. If the SfOrder 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 SfOrder with a shipments field.

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

const normalizers = defineNormalizers<typeof normalizersSFCC>()({
  ...normalizersSFCC,
  normalizeOrder: (order, context) => ({
    ...normalizersSFCC.normalizeOrder(order, context),
    shipments: order.shipments,
  }),
});

Source

šŸ”“ ../../node_modules/@vsf-enterprise/unified-api-sfcc/src/normalizers/orders/order.ts | Snippet does not exist šŸ”“ šŸ”“ ../../node_modules/@vsf-enterprise/unified-api-sfcc/src/normalizers/orders/orderListItem.ts | Snippet does not exist šŸ”“