window.Shoppex).
Script
Integration Modes
1) Declarative (data attributes)
The SDK auto-binds clickable elements matching:[data-shoppex-product-id][data-shoppex-checkout]
2) Programmatic (JavaScript API)
Data Attributes
| Attribute | Required | Description |
|---|---|---|
data-shoppex-product-id | Yes* | Product identifier |
data-shoppex-variant-id | No | Variant identifier |
data-shoppex-quantity | No | Quantity (1..999, default 1) |
data-shoppex-theme | No | light, dark, auto (default auto) |
data-shoppex-return-url | No | Return URL after checkout |
data-shoppex-email | No | Prefill customer email |
data-shoppex-coupon-code | No | Prefill coupon code |
data-shoppex-metadata | No | JSON object with string values |
data-shoppex-items | No | JSON array of checkout items |
data-shoppex-shop-id | No | Optional field in current API payload |
data-shoppex-checkout | No | Marker selector for custom triggers |
data-shoppex-items contains at least one valid item.
data-shoppex-metadata example:
JavaScript API
Shoppex.init(config?)
Initializes bindings and keyboard handlers.
- Usually optional because the script initializes automatically.
- Safe to call multiple times; first call wins.
Shoppex.open(options)
Opens modal checkout.
itemsmust contain at least one validproductId.- If more than one item is passed, current modal flow uses the first valid item.
- Calling
open()while a modal is open closes the old modal first.
Shoppex.close()
Closes the modal programmatically.
Events
Listen ondocument:
| Event | Detail |
|---|---|
shoppex:success | { invoiceId?: string } |
shoppex:error | { error?: string } |
shoppex:readyshoppex:resizeshoppex:close
URL Mapping
The SDK resolves checkout iframe URLs to:quantityvariantIdtheme(only when notauto)returnUrlemailcouponCodemetadata[key]=value
Runtime Behavior
- Modal uses Shadow DOM (
mode: closed) for style isolation. Escape, backdrop click, and close button all close modal.- Dynamically inserted buttons are auto-bound (MutationObserver).
- Message handling only accepts trusted checkout origins.
Practical Example
Need Faster Setup?
Copy/Paste Snippets
Framework snippets for Next.js, React, WordPress, and Webflow.