Skip to main content
Remark can hand off cart actions to your storefront instead of opening the default Remark checkout dialog. To do this, add a remarkOpenCart function to window. When a shopper clicks the cart action in the Remark header, the widget checks for window.remarkOpenCart. If the function exists, Remark calls it and lets your site open its own cart drawer, modal, or cart page.

Add the cart opener

Add this code to the storefront pages where the Remark widget is installed.
Returning true, or returning no value, tells Remark that your storefront handled the action. Returning false tells Remark to fall back to the default checkout dialog.
The function can be synchronous or asynchronous. Define it before shoppers can click the Remark cart action. If your cart script loads later, assign window.remarkOpenCart after your cart script is ready.

Function contract

Remark calls window.remarkOpenCart with a single context object.

Open cart after recommendation add-to-cart

By default, remarkOpenCart only runs when a shopper clicks the cart button in the Remark header. It does not automatically open your cart after a shopper adds a recommended product to cart. To also open your storefront cart after a user clicks the add-to-cart button on a recommendation, opt in with window.remarkOpenCartOnRecommendationAdd.
This opt-in only affects add-to-cart buttons on product recommendations shown in chat. If window.remarkOpenCart is missing, throws an error, or returns false, Remark will not open a fallback cart after recommendation add-to-cart since this isn’t the default behavior.

Common patterns

Open a cart drawer by clicking the site’s cart button

Most storefronts already have a cart button that opens the cart drawer. In that case, reuse the existing button instead of duplicating cart logic.

Call your storefront’s cart API

If your theme exposes a cart function, call it directly.

Redirect to your cart page

If your site does not have a cart drawer or modal, send the shopper to the cart page.

Fallback behavior

If the function is missing, throws an error, or returns false, Remark opens the default checkout dialog. Use this behavior intentionally: return false when your cart drawer cannot be opened, rather than leaving the shopper with no next step.

Test the integration

  1. Load a page with the Remark widget installed.
  2. Start a conversation.
  3. Add an item to your cart.
  4. Click the cart icon in the Remark header.
  5. Confirm your storefront cart opens.
  6. Temporarily return false from window.remarkOpenCart and confirm Remark falls back to the default checkout dialog.
  7. If you set window.remarkOpenCartOnRecommendationAdd = true, add a recommended product to cart from chat and confirm your storefront cart opens.