Add prescription verification using Script Manager and Handlebars
BigCommerce integration uses the built-in Script Manager to load the RxCompliant widget and Custom Fields on products to flag which ones require prescriptions. The Handlebars templates in your Stencil theme conditionally render the prescription gate.
Use Script Manager to add the widget JS globally.
Flag products with a 'requires_prescription' custom field.
Add Handlebars conditional to show the gate on flagged products.
Go to Storefront > Script Manager > Create a Script. Configure:
<!-- Add via BigCommerce Script Manager -->
<!-- Settings: -->
<!-- Name: RxCompliant Widget -->
<!-- Location: Footer -->
<!-- Pages: Storefront Pages -->
<!-- Script type: Script -->
<script src="https://rxcompliant.com/widget/rxcompliant.js"
data-api-key="YOUR_API_KEY"
data-color="#DC2626">
</script>For each product that requires a prescription, go to Products > Edit Product > Custom Fields. Add a new field:
Download your theme (Storefront > My Themes > Advanced > Edit Theme Files) or use Stencil CLI. Edit the product template to conditionally render the prescription gate:
<!-- In your product template (templates/pages/product.html) -->
<!-- Place before the Add to Cart button -->
{{#if product.custom_fields}}
{{#each product.custom_fields}}
{{#if name '==' 'requires_prescription'}}
{{#if value '==' 'true'}}
<div data-requires-rx
data-product-id="{{../../product.id}}"
data-product-title="{{../../product.title}}"
data-platform="bigcommerce">
</div>
{{/if}}
{{/if}}
{{/each}}
{{/if}}For cleaner organization, create a partial template:
<!-- Alternative: Using a Stencil component -->
<!-- Create components/products/rxcompliant-gate.html -->
{{#if product.custom_fields.length}}
{{#each product.custom_fields}}
{{#if name '==' 'requires_prescription'}}
<div class="rxcompliant-container"
data-requires-rx
data-product-id="{{../product.id}}"
data-product-title="{{../product.title}}"
data-platform="bigcommerce">
</div>
{{/if}}
{{/each}}
{{/if}}Then include it in your product template:
<!-- Include in your product.html template -->
<!-- Place inside the product form, before the add-to-cart button -->
{{> components/products/rxcompliant-gate}}requires_prescription: true custom field to a test product.Sign up for free and add prescription verification to your BigCommerce store.