sfcc-hooks-registration

Register SFCC hooks via cartridge package.json and hooks.json manifest.

27|9|Updated Aug 8, 2025
One-click install
npx skills add https://github.com/taurgis/sfcc-dev-mcp --skill sfcc-hooks-registration
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sfcc-hooks-registration
Source: https://github.com/taurgis/sfcc-dev-mcp/tree/main/ai-instructions/skills/sfcc-hooks-registration
Command: npx skills add https://github.com/taurgis/sfcc-dev-mcp --skill sfcc-hooks-registration

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Register SFCC hooks via cartridge package.json and hooks.json. Use when adding hooks or troubleshooting hook registration.

Core Features & Use Cases

  • Create a top-level cartridge package.json (cartridges/<cartridge-name>/package.json) and define the hooks path relative to that package.json.
  • Map hook names to script files in hooks.json relative to the location of hooks.json.
  • Export hook functions as CommonJS exports using the unqualified hook name (e.g., exporting "dw.order.calculate" as "exports.calculate").
  • Enable the Salesforce Commerce Cloud API hook execution feature switch in Business Manager for OCAPI/SCAPI hooks.
  • Ensure the cartridge is deployed to the site cartridge path and uploaded for use.
  • Notes:
  • The hooks path is relative to the package.json location.
  • The script path in hooks.json is relative to hooks.json itself.
  • For Shopper API hooks, returning a value can skip the system implementation; return nothing when you want the default implementation to run.

Quick Start

Create a top-level cartridge package.json, create hooks.json, map hooks to scripts, export the functions, enable the hook execution feature switch in Business Manager, and upload the cartridge.

Frequently Asked Questions about sfcc-hooks-registration

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I register SFCC hooks in a cartridge?

To register SFCC hooks, create a top-level cartridge package.json defining the hooks path, map hook names to script files in hooks.json, export functions as CommonJS exports, and enable the OCAPI/SCAPI hook execution feature in Business Manager.

Why are my SFCC hooks not triggering after deployment?

SFCC hooks may not trigger if the hooks.json mappings are incorrect, the package.json hooks path is misconfigured, the OCAPI/SCAPI hook execution feature switch is disabled in Business Manager, or the cartridge is not in the site cartridge path.

How do I export SFCC hook functions in script files?

Export SFCC hook functions as CommonJS exports using the unqualified hook name, such as exporting 'dw.order.calculate' as 'exports.calculate' in your script file for hooks.json to map correctly.

Do I need to enable a feature switch for SCAPI hooks in Business Manager?

Yes, you must enable the Salesforce Commerce Cloud API hook execution feature switch in Business Manager for OCAPI/SCAPI hooks to execute properly after cartridge deployment.

What happens when a Shopper API hook returns a value?

For Shopper API hooks, returning a value skips the system implementation entirely. Return nothing from the hook function when you want the default SFCC system implementation to run.

How are hook script paths resolved in SFCC hooks.json?

In SFCC hooks.json, the script path is resolved relative to the location of the hooks.json file itself, while the hooks path defined in package.json is resolved relative to the package.json location.