dw.order.TaxMgr
If no default tax class is defined, the method returns null.
If no default tax jurisdiction is defined, this method returns null.
Typical usage in tax calculation:
var TaxMgr = require('dw/order/TaxMgr');
calculateTaxes: function () {
Basket basket = BasketMgr.getCurrentBasket();
if ( basket.isExternallyTaxed() )
{
TaxMgr.applyExternalTaxation( basket );
}
else
{
// calculation with tax tables or customization
}
}
This method is intended for use in custom {@code dw.order.calculate} hook implementations (e.g., in SFRA or SiteGenesis) that override the default basket calculation. Calling this method instead of directly invoking {@code dw.order.calculateTax} ensures that Commerce App tax providers registered via {@code sfcc.app.tax.calculate} are invoked when available, with automatic fallback to the legacy {@code dw.order.calculateTax} hook or the platform default tax calculation.
WARNING: Do NOT call this method from within a {@code dw.order.calculateTax} hook implementation, as this will cause infinite recursion. This method is designed to be called from {@code dw.order.calculate} hooks only.
The dispatch precedence is:
- {@code sfcc.app.tax.calculate} — if a Commerce App tax provider is installed and the feature is enabled.
- {@code dw.order.calculateTax} — if registered by the storefront.
- Platform default tax calculation — using the site's tax tables.
Typical usage in a custom {@code dw.order.calculate} hook:
var TaxMgr = require('dw/order/TaxMgr');
exports.calculate = function (basket) {
// ... product prices, promotions, shipping ...
TaxMgr.applyTax(basket);
basket.updateTotals();
};
If no default tax class is defined, the method returns null.
If no default tax jurisdiction is defined, this method returns null.
Method returns null if no tax rate is defined.
Method returns 0.0 of 'nontaxable' tax rate is specified (see method 'getNontaxableTaxClassID'.