/cart.
The fix, in one line
After the builder’s add-to-cart finishes, tell the cart to refetch and open:Try
open_on_background_add first, since it often solves this without touching the button at all.The no-code option first
Aftersell detects adds it didn’t handle itself in two ways. Both run at all times — they are attached together at boot and neither suppresses the other, so one add can be announced by both — and each announcement applies the open rule independently:- On the wire. Aftersell watches for requests to Shopify’s cart endpoints. If the add followed a real click or keypress within about three seconds, it counts as shopper-driven, and the drawer opens according to your normal Open cart when an item is added setting. Any builder that adds through Shopify’s Ajax cart API (
/cart/add.js) lands here, which is the common case — so try your button first, it may already work with no changes at all. - Shopify’s standard cart events. An add announced this way is always treated as a background add, whether or not a shopper clicked. Background adds don’t open the drawer unless you opt in:
open_on_background_add also covers adds with no shopper gesture at all — another app or script writing to the cart. Turn it on only if you want those to pop the drawer too.Per-builder setup
Replo
- Open your page in the Replo editor and select the Add to Cart button.
- In the right sidebar, open the Interactions tab.
-
Under On Click, click
+and choose Run JavaScript. -
Paste:
- Select the Add Product to Cart interaction again and turn Go to cart after? off.
- Preview, confirm the drawer opens, then publish.
PageFly and GemPages
Both let you attach custom JavaScript to a button click or add a custom code element to the page. Use the same snippet, wired to run after the builder’s add-to-cart action, and disable any “redirect to cart” setting on the button.Your own button
If you’re adding to the cart yourself, skip the round trip and use the SDK’s own action, which updates the cart and can open the drawer in one step:refresh() only when something else changed the cart and you need Aftersell to catch up:
When the builder’s button should bypass Aftersell entirely
Sometimes the opposite is true: a form needs its own flow, and Aftersell’s interception gets in the way. Exempt just that form:data-skip-aftersell to the form. This is better than skip_add_to_cart_interceptor, which turns interception off for every form on the page.
Simpler still, if you can edit the form’s markup: add the class aftersell-cart-skip-atc to the <form> and Aftersell skips it, no script needed.
Troubleshooting
Check
window.aftersellCartDebugEvents if a call seems to do nothing, since SDK failures are swallowed rather than thrown.