BasketMergeHooks
CalculateHooks
CheckoutHooks
OrderHooks
PaymentHooks
ReturnHooks
ShippingOrderHooks
DID THIS ARTICLE SOLVE YOUR ISSUE?
Let us know so we can improve!
Let us know so we can improve!
This interface represents all script hooks that can be registered to customize the order and basket calculation functionality. It contains the extension points (hook names), and the functions that are called by each extension point. A function must be defined inside a JavaScript source and must be exported. The script with the exported hook function must be located inside a site cartridge. Inside the site cartridge a ‘package.json’ file with a ‘hooks’ entry must exist.
1"hooks": "./hooks.json"The hooks entry links to a json file, relative to the ‘package.json’ file. This file lists all registered hooks inside the hooks property:
1"hooks": [
2 {"name": "dw.order.calculate", "script": "./calculate.js"}
3]A hook entry has a ‘name’ and a ‘script’ property.
| Constant | Description |
|---|---|
| extensionPointCalculate: String = “dw.order.calculate” | The extension point name dw.order.calculate. |
| extensionPointCalculateShipping: String = “dw.order.calculateShipping” | The extension point name dw.order.calculateShipping. |
| extensionPointCalculateTax: String = “dw.order.calculateTax” | The extension point name dw.order.calculateTax. |
This class does not have a constructor, so you cannot create it directly.
| Method | Description |
|---|---|
| calculate(LineItemCtnr) | The function is called by extension point extensionPointCalculate. |
| calculateShipping(LineItemCtnr) | The function is called by extension point extensionPointCalculateShipping. |
| calculateTax(LineItemCtnr) | The function is called by extension point extensionPointCalculateTax. |
assign, create, create, defineProperties, defineProperty, entries, freeze, fromEntries, getOwnPropertyDescriptor, getOwnPropertyNames, getOwnPropertySymbols, getPrototypeOf, hasOwnProperty, is, isExtensible, isFrozen, isPrototypeOf, isSealed, keys, preventExtensions, propertyIsEnumerable, seal, setPrototypeOf, toLocaleString, toString, valueOf, values
The extension point name dw.order.calculate.
The extension point name dw.order.calculateShipping.
The extension point name dw.order.calculateTax.
The function is called by extension point extensionPointCalculate. It provides a single place for the line item container calculation.
To provide a fallback for existing implementations, the default implementation calls the hook dw.ocapi.shop.basket.calculate. However, this hook is deprecated, and calling it will create entries in the deprecated API usage logs. You should override this function to use dw.order.calculate instead.
If you provide your own implementation, you should provide and use the following hooks. Best practice is to use the hook manager to retrieve them in the calculate hook, and avoid calling them directly.
Parameters:
The function is called by extension point extensionPointCalculateShipping. It provides a single place for shipping calculation during the line item container calculation.
Parameters:
The function is called by extension point extensionPointCalculateTax. It provides a single place for tax calculation during the line item container calculation.
Parameters: