> ## Documentation Index
> Fetch the complete documentation index at: https://docs.joinerywp.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Price preview

> Ask what a product costs at any quantity, for the current customer.

```
GET /wp-json/joinery/v1/price-preview?product_id=10&quantities=1,12,60
```

| Parameter | Required | Description |
| - | - | - |
| `product_id` | Yes | A published, purchasable product or variation ID. |
| `quantities` | No | Up to 10 quantities, comma-separated. Leave it out to get the product's quantity breaks. |

```json Response theme={null}
{
  "product_id": 10,
  "currency_code": "USD",
  "currency_minor_unit": 2,
  "regular_price": "1200",
  "prices": [
    { "quantity": 1, "price": "1200", "percent_saving": 0 },
    { "quantity": 12, "price": "1080", "percent_saving": 10 },
    { "quantity": 60, "price": "960", "percent_saving": 20 }
  ]
}
```

Prices are unit prices before tax, in minor units. The preview treats the product as the only item in the cart. Cart-level rules, such as "10% off orders over €100", apply in the cart and don't appear here.

## Example: Next.js

```tsx app/products/[id]/price-table.tsx theme={null}
const money = (minor: string, currency: string) =>
  new Intl.NumberFormat('en', { style: 'currency', currency }).format(Number(minor) / 100)

export async function PriceTable({ productId }: { productId: number }) {
  const response = await fetch(
    `${process.env.WORDPRESS_URL}/wp-json/joinery/v1/price-preview?product_id=${productId}`,
    { next: { revalidate: 300 } }, // guest prices only; don't cache signed-in requests
  )
  const preview = await response.json()

  return (
    <table>
      <tbody>
        {preview.prices.map((row) => (
          <tr key={row.quantity}>
            <td>{row.quantity}+</td>
            <td>{money(row.price, preview.currency_code)}</td>
          </tr>
        ))}
      </tbody>
    </table>
  )
}
```

## Errors

| Status | Code | When |
| - | - | - |
| 400 | `rest_invalid_param` | `product_id` is missing, or `quantities` isn't a comma-separated list of numbers. |
| 404 | `joinery_product_not_found` | The product doesn't exist, isn't published or can't be bought. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.