Skip to main content
The Genlook widget exposes a JavaScript SDK on window.Genlook.cabin that you can use to control the widget programmatically from your theme code.
The SDK is available on every product page where the Genlook widget block is installed in the Shopify theme editor, even if try-on is disabled for the current product.

API Reference

Genlook.cabin.enabled

Type: boolean Whether virtual try-on is enabled on the current product page. This is determined by the product and collection metafield settings configured in the Genlook admin.
if (window.Genlook?.cabin?.enabled) {
  // Try-on is available -- show your custom UI
}

Genlook.cabin.open()

Opens the try-on widget modal. The widget is lazy-loaded on first call — subsequent calls open instantly.
window.Genlook.cabin.open();

Genlook.cabin.fetch(url, options)

Authenticated fetch through the Shopify app proxy. Use this for all endpoint calls.
const response = await window.Genlook.cabin.fetch('/check-credits');
const { allowed } = await response.json();
The base path (/apps/proxy_genlook-x/public) is prepended automatically.

Custom Button

To replace the default try-on button with your own, enable “Hide Built-in Button” in the widget block settings, then add a button anywhere in your theme:
<button class="genlook-custom-button" onclick="window.Genlook.cabin.open()">
  Virtual Try-On
</button>
The genlook-custom-button CSS class is automatically hidden by the widget when try-on is not enabled on the current product. This means you can place the button in your product template without conditional logic — it will only appear on enabled products.

Conditional rendering with JavaScript

If you need more control (e.g. changing layout based on availability):
document.addEventListener('DOMContentLoaded', () => {
  const btn = document.getElementById('my-tryon-btn');
  if (window.Genlook?.cabin?.enabled) {
    btn.style.display = 'block';
    btn.addEventListener('click', () => window.Genlook.cabin.open());
  }
});
For server-side conditional rendering in Liquid, see the Liquid Guide.