Skip to main content
The cart operations extension inspects the current cart and returns cart mutations for the app to apply.

Exported function

Export the function from your entry file under the extension’s functionName in napps.config.json. See How App Extensions work. The examples on this page name it onCartChanged.
Create the returned mutations with CartOperations. It is a runtime global, also available as NAPPS.CartOperations; @napps/component-extension exports its type only, so do not import it as a value. Its type is CartOperations | undefined because not every surface registers it, so check it before use. See Cart operations and Data models.

Execution behavior

  • The app can call the hook repeatedly, up to three passes.
  • Each pass receives the latest cart, after the previously returned operations are applied.
  • The app drops conflicting operations.
  • Return an empty array when no change is needed.
  • Async work must complete within the extension’s three-second execution budget.
Keep the hook idempotent: repeated passes should converge instead of producing new operations every time.