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
Relabel a line
Control the order
A comparator takes the same shapeArray.prototype.sort expects, and runs after hiding and renaming:
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 publiccart-external-* class:
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
aftersellCartDebugEventswhile developing. registerLineTransformreturns an unregister function, if you need to undo it later.
Where to go next
- Hooks: the full hook reference.
- Cart object: every field you can branch on.
- Custom CSS: the
cart-external-*class convention.