Skip to content

Storefront Events: Redirect After a Quote and Custom Open Button

For merchants with a theme developer, or when BSS support helps with your theme. The app fires events on the storefront that your theme code can listen to. You do not need a library or any change to the app.

The events are dispatched on document.head and bubble up to document, so document.addEventListener works.

Redirect to a thank-you page after a quote is sent

Section titled “Redirect to a thank-you page after a quote is sent”

The event bcpR4q:submitQuoteSuccess fires as soon as a quote is sent successfully, before the form shows its thank-you step. It has no detail (no quote ID). If you redirect immediately, customers will not see the thank-you step, so wait a few seconds.

<script>
document.addEventListener("bcpR4q:submitQuoteSuccess", function () {
setTimeout(function () {
window.location.href = "/pages/thank-you-quote"; // use a page of your own shop
}, 2500);
});
</script>

Add it to theme.liquid before </body> (or in the theme’s custom code section). Use a path of your own shop only. Never build the URL from visitor input.

Every built-in entry point of the app (the floating widget, the “view quote” toast) fires the same event, bcpR4q:openForm. A custom button, for example a quote icon in your header, can do the same:

<script>
document.addEventListener("click", function (event) {
if (!event.target.closest(".my-quote-icon")) return; // class of your custom button
event.preventDefault();
document.head.dispatchEvent(
new CustomEvent("bcpR4q:openForm", { bubbles: true, composed: true, detail: {} })
);
});
</script>

Things to know:

  • The form lists the products the customer already added to the quote list (with the quote button on a product or collection page). With an empty list there is nothing to send.
  • The form only opens on pages where Request for Quote runs for that customer. On other pages nobody listens to the event.
  • To close the form from code, fire bcpR4q:closeForm the same way.
  • If the floating widget covers another button (for example Checkout on mobile), hide the widget with the display conditions in the app and use your own button as above.

If your theme overrides scripts, uses an unusual ajax cart or lazy loading, or you need another event (for example the quote ID after sending), contact support instead of editing app code.