SDK Shopify Plugin

The Stylux JavaScript SDK has an optional Shopify plugin that can be enabled to make the frontend integration for standard Shopify significantly easier. The Stylux Shopify Plugin automatically integrates with Shopify's AJAX API to handle cart behavior after the BUNDLE_CREATE event is emitted, automatically balance cart items, and more.

Note: for headless Shopify integrations you'll likely not want to use this plugin.

Getting Started

When initializing the SDK you can enable the plugin as follows:

(async function () {
  if (!self.Stylux) {
    return;
  }

  await Stylux.setup({
    apiKey: 'STLX_key-for-unsigned-requests',
    merchantId: 'merchant-id',

    plugins: {
      shopify: true,
    },
  });
})();

Configuration

A complete list of optional configuration options for the Shopify plugin is listed below:

Configuration NameData TypeDescription
detectVariantChangesbooleanWhether to automatically detect variant changes (defaults to true)
normalizeCartbooleanWhether to automatically normalize/balance Stylux cart items (defaults to true)
addToCartSelectorstringThe default selector matching the element triggering add to cart (defaults to [name="add"], [name="add"] *)
overrideAddToCartbooleanWhether to override the add to cart button to trigger the Stylux modal for products eligible for personalization (defaults to true)
sectionsForCartRequestsstring[]When interacting with Shopify's AJAX cart API you can specify sections to fetch; this configures sections to include in these requests
afterUpdateCart(addToCartResponse: unknown) => voidA function that's optionally called after any cart updates via Shopify's AJAX API
getQuantity() => numberA function to optionally get the current selected quantity