Global

Methods

normalizeCartMoneyFieldDecimalPlaces()

Normalize all currency fields in the checkout payload to contain the same number of decimal places that would be returned by the storefront API.

In the storefront API, currency amounts are returned as a string that contains 1 decimal place (if the 2nd decimal place is 0) or else 2 decimal places.

In our mapping functions, we are typically converting to strings with 2 decimal places. In case any clients of the JS Buy SDK are relying only a single decimal place being returned in some cases, we want to normalize the decimal places.

Source:

shouldReturnWithOneDecimalPlace(currency) → {boolean}

Whether the SF API would return this amount with 1 decimal place (as opposed to 2 decimal places). See normalizeCartMoneyFieldDecimalPlaces for more information.

Parameters:
Name Type Description
currency string

field to check

Source:
Returns:

whether the SF API would return this amount with 1 decimal place

Type
boolean