Before you write a script
A lot of what merchants used to script is now a built-in setting. Check this first, because a setting keeps working through cart redesigns and your script might not:
Reach for the SDK when the logic is genuinely yours: a rule no setting expresses, an integration with another app, or data only your store has.
How to use these
Paste a snippet into your cart’s Initialization script. In the cart editor, go to Cart settings → Custom script → Initialization. Write plain JavaScript; no<script> tags. See Custom scripts for the details.
The use cases
Track add-to-cart in a third-party tool
Send cart events to Klaviyo, Triple Whale, GA4, or any analytics pixel.
Auto-add a free gift at a threshold
Add a gift when the total crosses a threshold, remove it when it drops back.
Hide and relabel cart lines
Hide app-injected or free lines, rename them, and control their order.
Show metafield data on cart lines
Pull a delivery estimate, badge, or any metafield onto every line.
Open the drawer from a page builder
Make Replo, PageFly, GemPages, and custom buttons open the cart.
Require terms before checkout
Block checkout until the shopper accepts your terms.
Group bundle lines from another app
Make a bundle app’s separate cart lines render as one item.