İçeriğe geç

Shopify connector

Bu içerik henüz dilinizde mevcut değil.

The Shopify connector replaces the manual cart wiring with one pasted snippet. It reads your own storefront’s product data and needs no app install, API keys or theme code:

  1. Maps your Shopify variants to the configurator by SKU. The SKUs you typed in the Togenar editor are the join key, so there is nothing to configure twice.
  2. Pushes each variant’s price and stock into the configurator. The summary shows a live total in your store’s currency and sold-out options are dimmed.
  3. Wires any button marked data-togenar-add-to-cart: disabled until the selection maps to your catalogue, then one click adds every configured part to the cart, with the configuration’s share link stored on each line item.

One product template serves every configurable product. Each product names its Togenar project in a metafield.

  1. Metafield definition. In the Shopify admin, add a product metafield definition with the namespace and key togenar.project and the type Single line text.
  2. Product template. In the theme editor, create a product template for configurable products, for example configurator. In that template, remove the theme’s price, variant picker, quantity selector and buy buttons blocks.
  3. Snippet. Add a Custom Liquid block where those blocks were and paste the snippet. The panel writes it: open any project’s Embed code dialog and pick Shopify (Custom Liquid). The snippet is the same for every project.
{%- assign togenar_project = product.metafields.togenar.project.value -%}
{%- if togenar_project != blank -%}
<script type="module" src="https://model.togenar.com/embed/togenar-embed.js"></script>
<script type="module" src="https://model.togenar.com/embed/togenar-shopify.js"></script>
<togenar-embed
project="{{ togenar_project | escape }}"
configurator
ar-button
shopify
shopify-handles="{{ product.handle }}"
shopify-currency="{{ cart.currency.iso_code }}"
shopify-locale="{{ request.locale.iso_code }}">
</togenar-embed>
<button data-togenar-add-to-cart disabled>
{{ 'products.product.add_to_cart' | t }}
</button>
{%- endif -%}
  1. On the product’s admin page, set Theme template to the template you created.
  2. Enter the project’s ID in the togenar.project metafield. The Embed code dialog shows the ID under the snippet.

A product whose metafield is empty renders nothing from the snippet. A product CSV import fills the metafield for many products at once through a product.metafields.togenar.project column.

The embed opens the project’s first scene.

Attribute Meaning Default
shopify Enables the connector for this embed. None
shopify-handles Comma-separated product handles to map. The current /products/{handle} page
shopify-currency ISO code shown with prices. window.Shopify.currency.active
shopify-locale Locale used to format prices. The page language
shopify-goto-cart cart redirects to the cart page after a successful add. Stay on the page
shopify-ar-return off disables the automatic add when a shopper returns from the AR hand-off. On

A configurator whose parts are sold as separate Shopify products works the same way. List every handle:

shopify-handles="oslo-sofa,oslo-legs,oslo-cushions"

Each selected part becomes its own cart line. A selected SKU that none of the listed products carries is left out of the cart and logged in the browser console, so a missing handle surfaces during your first test click, not in an order.

Every cart line added by the connector carries the configuration’s share link as a hidden line-item property. It travels through checkout onto the order, where clicking it reopens the exact configuration the shopper bought.

The connector dispatches the standard commerce events on the embed element: togenar:commerce:add_to_cart_success (with Shopify’s cart response) and togenar:commerce:add_to_cart_fail (with Shopify’s error message, e.g. sold out). Themes with a cart drawer can listen for the success event to open it.

  • The store must run on the Online Store channel. The connector reads the storefront’s own product and cart endpoints, which headless or Buy-Button-only setups don’t serve.
  • Products must be published to the Online Store channel, or their product JSON is not available.
  • Variant SKUs in Shopify must match the SKUs entered in the Togenar editor. The SKU rules apply unchanged.
  • Prices come from Shopify’s own storefront API, so Shopify Markets multi-currency works. Third-party currency-converter apps that rewrite prices in the DOM do not affect what the connector shows.

If you wire the cart yourself or use another platform, the manual pattern remains fully supported. The connector uses the same contract.