İçeriğe geç

Methods reference

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

Methods are called directly on the element (const tg = document.getElementById('tg')).

Instant, served from the cached last selection_change. Return null / [] until the first event arrives.

Current configuration: { parts: [{ partId, partLabel, variantId, label, sku, modelName }], shareUrl }.

The SKUs of the current configuration, one per configurable part — the cart payload: ["OSLO-BODY-WALNUT", "OSLO-LEGS-CHROME"].

Deep-link URL that rebuilds the current configuration exactly. Persist it on the order line — it is the one field worth storing beyond the SKUs.

Async — each returns a Promise.

Enumerate every part + all its variants with select()-ready handles. Resolves to [{ partId, partKey, label, defaultVariantId, variants: [{ variantId, handle, label, sku, swatch, swatchImage, modelName, isDefault, available }] }].

Drive a selection from your own UI. Keys are the URL handles (select('body', 'walnut')). Resolves with { ok, selection } after the model swap settles; rejects on unknown handle or timeout.

Back to the published default. Resolves with { ok, selection }.

Push live stock: setAvailability({ body: { walnut: false } }) — keys are the same handles getOptions() returns; false = out of stock. Out-of-stock swatches dim, strike through and become unselectable in the built-in picker; getOptions() then reports each variant’s available. Resolves with { ok, applied }.

Push price display from your catalogue:

tg.setPrices({ currency: 'EUR', locale: 'de-DE', items: { 'SKU-1': 129.9 }, total: 259.8 });

Keys are the same SKUs the events report. Numbers are Intl-formatted with currency/locale; strings are shown verbatim; total is optional (auto-summed when every shown price is numeric). Prices appear in the viewer’s summary. Pass null to clear. Resolves with { ok, applied }.

Ease the camera back to its opening framing. Resolves with { ok }.

Launch AR (iOS Quick Look / Android Scene Viewer / WebXR). Call from your own click handler — WebXR may require an in-page user gesture. Resolves with { ok }.

PNG data-URL of the currently-configured model (the summary hero image). Resolves { ok, url } — best-effort, ok: false when capture is unavailable.

Short device-adaptive share link (…/s/{code}) for the current configuration — the same link the built-in summary’s Share box and QR encode. Resolves { ok, url } (falls back to the full launcher URL).

QR PNG data-URL for the desktop “scan to view in AR” flow. Defaults to the short share link; pass { text, size } to encode something else. Resolves { ok, url }.

Async methods can be called before the viewer is ready — requests queue and flush once the viewer’s bridge is up. Default timeout: 30 s.