Skip to main content
Hide lines the shopper shouldn’t see, rename lines that read badly, and control the order everything renders in, all without touching what’s actually in the cart. This replaces the older pattern of hiding cart elements with CSS or style.display = 'none'. A line transform is applied every time the cart renders, so it survives updates, re-renders, and drawer re-opens.

Hide a line

Hiding is not removing. A hidden line stays in the shopper’s cart, stays in the total, and goes through to checkout; it just isn’t drawn in the drawer. It does drop out of getCart().items and itemCount, so your own code stops seeing it too. If you want it gone for real, use removeItem.
Common things worth hiding:

Relabel a line

The four setters available on a line:

Control the order

A comparator takes the same shape Array.prototype.sort expects, and runs after hiding and renaming:
Return 0 for pairs you don’t care about. Comparators compose as tie-breakers, so the first to return a non-zero value decides that pair and returning 0 hands the decision to the next one instead of forcing an order on it.

Hide a whole block, not a line

A line transform works on cart lines. To show different block settings by country, market, or currency (for example different Rewards tiers), use conditions in the cart editor. No code required, and it survives cart redesigns. Cart total and cart contents are not editor condition types. Reach for the SDK when your rule is something conditions can’t express (product IDs in the cart, a custom total, and so on). In that case, query the shadow root for a public cart-external-* class:
This runs after each render, so the block can flash into view before your code hides it. Conditional rendering doesn’t have that problem, so prefer it wherever it fits.

Things to get right

  • Transforms are set-up calls. Register them at the top of your Initialization script; no ready() needed.
  • Everyone’s transforms run. Yours composes with any registered by other apps. You can’t replace theirs, and they can’t drop yours.
  • A transform can’t change price, quantity, or identity. It only changes what renders. Use the actions for real changes.
  • A transform that throws is skipped silently. The rest still run. Check aftersellCartDebugEvents while developing.
  • registerLineTransform returns an unregister function, if you need to undo it later.

Where to go next