# Pricing & Availability

### Item Prices and Availability

Pricing and availability for individual items and services are displayed in the Spectrum UI, with data provided by the `spectrumItemPricesAndAvailabilityCallback` function. This function has one argument in the signature: `skus`.

```javascript
window.spectrumItemPricesAndAvailabilityCallback = function(itemsBySkuOrName) { 
  // itemsBySkuOrName: array of strings that can refer to SKUs, parts, or decoration services
}
```

This callback should return a promise that resolves to an array of objects with the following properties:

```javascript
[
  {
    sku: 'exampleSku',
    name: 'Example',
    type: 'baseProduct',
    price: 99.99,
    listPrice: null,     // nullable list price to distinguish from sale price
    isoCurrency: 'USD',  // must be a valid ISO 4217 currency code
    inStock: true,
    options: null        // nullable options object with string values
  }
]
```

### Total Price

Displaying the total price for a customized product at runtime can be supported by exposing a global `spectrumTotalPriceCallback` function. This ensures that ecommerce systems are the single source of truth pricing calculations and ensures that discounts, upcharges are accurate and consistent with how they appear at checkout.

```javascript
window.spectrumTotalPriceCallback = function(items) {
  // items[n].sku: string | null
  // items[n].name: string | null
  // items[n].quantity: number (unsigned int)
}
```

This callback should return a promise that resolves into an object with the following properties:

```javascript
{
  price: 999.99,
  isoCurrency: 'USD',  // must be a valid ISO 4217 currency code
  options: null        // nullable options object with string values
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.spectrumcustomizer.com/integration/ecommerce/pricing-and-availability.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
