Cert++
Close

Multiple hook registrations and cartridge path execution order

Key Takeaway

When a custom extension point is called, every module registered for it runs, in every cartridge on the cartridge path. Modules in cartridges listed earlier run first, but you can't control the order of several modules registered in one hooks.json file.

A hook is a script module that a cartridge registers for a named extension point. One extension point can have more than one module registered for it, either in one cartridge's hooks.json file or in several cartridges. B2C Commerce runs these modules in an order set by the cartridge path. What happens to their return values depends on whether the extension point is a custom extension point or a Shopper API extension point. Together, these rules decide which code runs, in what order, and which result comes back.

Two kinds of extension points

Each extension point is either a custom extension point or a Shopper API extension point. The two kinds differ in how they are named and how they are called.

Custom extension pointsShopper API extension points
NameA name you define, such as app.payment.processor.defaultUses the dw.ocapi.shop.* prefix
How it's calledStorefront code calls dw.system.HookMgr.callHook(extensionPoint, functionName, args)The same hooks are called for both SCAPI and OCAPI requests
B2C Commerce Developer Study Guide

Checklist progress

0/237Learned

Given a use case, extend functionality or capture an event using hook extension points

0/6

Prepare for the Exam

Play Today's Certle

Study Community

Ask questions and get the latest info from other B2C Commerce Developer studiers. 796 members and growing.