Перейти к содержимому

Prices in the configurator

Это содержимое пока не доступно на вашем языке.

The viewer never computes a price and never holds a cart. This is the commerce boundary. If you want prices shown inside the configurator, push them from your own catalogue and they are displayed verbatim.

await tg.setPrices({
currency: 'EUR',
locale: 'de-DE',
items: {
'OSLO-BODY-WALNUT': 129.9, // keyed by the SAME SKUs the events report
'OSLO-LEGS-CHROME': 129.9,
},
total: 259.8, // optional
});

Prices appear in the viewer’s summary view, next to each configured part.

  • Numbers are formatted with Intl.NumberFormat using your currency + locale. For example, 129.9 becomes 129,90 € for de-DE/EUR.
  • Strings are shown verbatim. Pre-format them yourself when you need something custom ('129,90 € *').
  • total is optional. When every shown price is numeric it is auto-summed. Pass it explicitly when you apply bundle discounts.

Call setPrices() again whenever your price changes (currency switch, customer group, promotion). Each call replaces the previous state. Pass null to remove all price display.

Recompute on every selection change so part swaps reprice immediately:

tg.addEventListener('togenar:configurator:selection_change', async (e) => {
const skus = (e.detail.parts || []).map(p => p.sku).filter(Boolean);
const priced = await fetch('/api/prices?skus=' + skus.join(',')).then(r => r.json());
tg.setPrices({ currency: priced.currency, locale: priced.locale, items: priced.items });
});