Price Conversion

Customize how product prices are displayed in the Alhena chat widget using convert price hooks.

The convert price hook lets you transform product prices before they are displayed in product cards. The hook function receives the original price and a metadata object, and should return the formatted price string.

Hook Signature

function convertPrice(price, metadata) { ... }
Argument
Type
Description

price

string

The original product price (e.g., "$29.99")

metadata.variantId

string | undefined

The external variant ID of the product

Setting the Hook

There are two ways to set the hook:

At initialization

document.gleenConfig = {
  company: "your-company-key",
  apiBaseUrl: "https://app.alhena.ai",
  convertPrice: function (price, metadata) {
    return price;
  },
};

After widget load

Use setConvertPriceHook when the hook needs to be set or updated dynamically after the widget has loaded.

Examples

Currency Conversion

Variant-Aware Pricing

Use metadata.variantId to show different prices per product variant — for example, sale prices or region-specific pricing.

Locale-Based Formatting

Last updated