Skip to main content

Widget: Show passes and subscriptions together in one widget

You can show passes and subscriptions in one widget by placing both widgets on the same page and adding a short script after them. The script in this article moves the subscriptions inside the passes container, so members see one pricing section.


Step 1: Generate both widget codes

Generate the code for each widget in your back office, one after the other.

  1. Go to Settings > Widgets.

  2. Under "Choose a component", select Passes, set your options (for example, which pass categories to show), and copy the code.

  3. Go back, select Subscription, set your options, and copy the code.

Keep both codes handy. You will paste them together in the next step.

Step 2: Paste both widgets together

Paste the Subscription code, then the Passes code, one after the other in the same HTML or code block on your page. Do not edit either code.

The example below shows both widgets together. The companyId is a placeholder: your own codes contain your real company ID and widget ids.

<!-- Subscription widget -->
<script id="insert-bsport-widget-cdn">!function (b, s, p, o, r, t) { typeof window.BsportWidget === "undefined" && !document.getElementById("bsport-widget-cdn") && !function () { m = b.createElement(s), m.id = "bsport-widget-cdn", m.src = p, b.getElementsByTagName("head")[0].appendChild(m) }() }(document, "script", "https://cdn.bsport.io/scripts/widget.js")</script>
<script id="bsport-widget-mount">
function MountBsportWidget(config, repeat=1) {
if (repeat > 50) { return }
if (!window.BsportWidget) {
return setTimeout(() => {
MountBsportWidget(config,repeat+1)
}, 100 * repeat || 1)
}
BsportWidget.mount(config)
}
</script>
<script>
MountBsportWidget({
"parentElement": "bsport-widget-337136",
"companyId": yourcompanyId,
"franchiseId": null,
"dialogMode": 1,
"widgetType": "subscription",
"showFab": false,
"fullScreenPopup": false,
"styles": undefined,
"config": {
"subscription": {}
}
})
</script>
<div id="bsport-widget-337136"></div>

<!-- Passes widget -->
<script id="insert-bsport-widget-cdn">!function (b, s, p, o, r, t) { typeof window.BsportWidget === "undefined" && !document.getElementById("bsport-widget-cdn") && !function () { m = b.createElement(s), m.id = "bsport-widget-cdn", m.src = p, b.getElementsByTagName("head")[0].appendChild(m) }() }(document, "script", "https://cdn.bsport.io/scripts/widget.js")</script>
<script id="bsport-widget-mount">
function MountBsportWidget(config, repeat=1) {
if (repeat > 50) { return }
if (!window.BsportWidget) {
return setTimeout(() => {
MountBsportWidget(config,repeat+1)
}, 100 * repeat || 1)
}
BsportWidget.mount(config)
}
</script>
<script>
MountBsportWidget({
"parentElement": "bsport-widget-421437",
"companyId": yourcompanyId,
"franchiseId": null,
"dialogMode": 1,
"widgetType": "pass",
"showFab": false,
"fullScreenPopup": false,
"styles": undefined,
"config": {
"pass": {
"paymentPackCategories": [],
"privatePassCategories": []
}
}
})
</script>
<div id="bsport-widget-421437"></div>


Step 3: Add the script after both widgets

Paste this script right after the Passes widget code, in the same code block.

It waits until both widgets have loaded, then moves the subscriptions into the passes container. It checks every 0.3 seconds.
​

<script>
function appendSubs() {

const subs = document.querySelector(".bs-contract-page");
if (!subs) {
setTimeout(appendSubs, 300);
return;
}

const passes = document.querySelector(".bs-pass-page__list");
if (!passes) {
setTimeout(appendSubs, 300);
return;
}

passes.appendChild(subs);
}

document.addEventListener("DOMContentLoaded", () => {
appendSubs();
})
</script>


Publish the page. Your members now see subscriptions inside the passes list.

Did this answer your question?