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.

Open the quote form and read the count from theme code

Section titled “Open the quote form and read the count from theme code”

If you build your own header icon, the storefront script also gives you two functions and one event. They are ready as soon as the script runs, so they work before the page finishes loading. The B2B Portal app embed must be on.

Call What it does
BSS_BCP_V2.r4q.openForm() Opens the quote form (pop-up) or goes to the quote page, as your quote logic says. Returns true, or false when the visitor matches no quote logic (for example another customer group).
BSS_BCP_V2.r4q.getCartCount() The total quantity in the quote list. 0 when the list is empty. It is the number the floating widget shows.
bcpR4q:cartChange (event) Fires on every change of the quote list, also from another browser tab. event.detail is { count, lines }: total quantity and number of lines.
<script>
document.addEventListener("bcpR4q:cartChange", function (event) {
document.querySelector(".my-quote-badge").textContent = event.detail.count;
});
document.addEventListener("click", function (event) {
if (!event.target.closest(".my-quote-icon")) return;
event.preventDefault();
window.BSS_BCP_V2 && window.BSS_BCP_V2.r4q.openForm();
});
</script>

You do not need to code an icon in most cases. The app can add one for you: see Quote icon in the header.

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.