SFRA Server-side Javascript - Module: calculate menu

SFRA / Server-side JS / Module: calculate

Members

(inner) HashMap

This javascript file implements methods (via Common.js exports) that are needed by the new (smaller) CalculateCart.ds script file. This allows OCAPI calls to reference these tools via the OCAPI 'hook' mechanism

Source:

Methods

(inner) calculate calculate is the arching logic for computing the value of a basket. It makes calls into cart/calculate.js and enables both SG and OCAPI applications to share the same cart calculation logic.(basket)

Parameters:
Name Type Description
basket object

The basket to be calculated

Source:

(inner) calculateGiftCertificates Function sets either the net or gross price attribute of all gift certificate line items of the basket by using the gift certificate base price. It updates the basket in place.(basket)

Parameters:
Name Type Description
basket object

The basket containing the gift certificates

Source:

(inner) calculateProductPrices Calculates product prices based on line item quantities. Set calculates prices on the product line items. This updates the basket and returns nothing(basket)

Parameters:
Name Type Description
basket object

The basket containing the elements to be computed

Source:

(inner) calculateTax

Determines tax rates for all line items of the basket. Uses the shipping addresses associated with the basket shipments to determine the appropriate tax jurisdiction. Uses the tax class assigned to products and shipping methods to lookup tax rates.

Sets the tax-related fields of the line items.

Handles gift certificates, which aren't taxable.

Note that the function implements a fallback to the default tax jurisdiction if no other jurisdiction matches the specified shipping location/shipping address.

Note that the function implements a fallback to the default tax class if a product or a shipping method does explicitly define a tax class.(basket)

Parameters:
Name Type Description
basket dw.order.Basket

The basket containing the elements for which taxes need to be calculated

Source: