Vue Storefront is now Alokai! Learn More
Money normalizer

Money normalizer

The normalizeMoney function maps SFCC price values into Unified SfMoney.

Parametersri:link

NameTypeDefault valueDescription
contextNormalizerContextContext needed for the normalizer.
pricePrice in SFCC Product it's float.SFCC price

Extendingri:link

The SfMoney is returned as a part of multiple models, as for example SfProduct, SfProductCatalogItem, and SfCart. If you want to extend the SfMoney with custom fields, you should use the addCustomFields API.

Sourceri:link

money.ts
import { defineNormalizer } from "../defineNormalizer";

export const normalizeMoney = defineNormalizer.normalizeMoney((context, amount) => {
  return {
    amount,
    currency: context.currency,
    precisionAmount: amount.toFixed(2),
  };
});