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

# JavaScript helpers

> The pricing, status and formatting helpers published on the admin page

export const Media = ({kind = 'Screenshot', children}) => <div style={{
  display: 'flex',
  flexDirection: 'column',
  alignItems: 'center',
  justifyContent: 'center',
  gap: '0.5rem',
  textAlign: 'center',
  padding: '2.75rem 1.5rem',
  margin: '1.5rem 0',
  border: '1.5px dashed #b4c0d4',
  borderRadius: '0.75rem',
  background: 'rgba(148, 163, 184, 0.07)'
}}>
    <span style={{
  fontSize: '1.5rem',
  lineHeight: 1
}}>
      {kind === 'Video' ? '▶️' : '🖼️'}
    </span>
    <span style={{
  fontSize: '0.75rem',
  fontWeight: 700,
  letterSpacing: '0.08em',
  textTransform: 'uppercase',
  color: '#64748b'
}}>
      {kind} pending
    </span>
    <span style={{
  fontSize: '0.875rem',
  color: '#64748b',
  maxWidth: '34rem'
}}>
      {children}
    </span>
  </div>;

export const Pro = () => <span style={{
  display: 'inline-flex',
  alignItems: 'center',
  verticalAlign: 'middle',
  fontSize: '0.68em',
  fontWeight: 700,
  letterSpacing: '0.07em',
  lineHeight: 1,
  padding: '0.32em 0.55em',
  borderRadius: '0.3em',
  background: '#f5b301',
  color: '#2b2000',
  marginLeft: '0.4em',
  textTransform: 'uppercase'
}}>
    Pro
  </span>;

`window.CartPresetsAdmin` is set on CartPresets' own admin page. It exposes three helpers — the things another plugin extending this admin would otherwise reimplement and get subtly wrong.

<Warning>
  This exists on the plugin's **admin page only**. Nothing is enqueued on your storefront, so there is no front-end equivalent and there will not be one.
</Warning>

```js theme={null}
const { pricing, status, format, version } = window.CartPresetsAdmin;
```

## pricing

The same arithmetic the editor and the cart both use, pinned to the PHP by a shared fixture table.

```js theme={null}
pricing.presetTotals( items, settings );
```

Returns the whole computation: per-row unit and line prices, the subtotal, the item discount total, the preset-level discount and the final total. It is what the editor's live summary draws.

Use it rather than reimplementing the two-pass model — source price, per-item discount, then a pro-rata distributed preset discount with the rounding drift placed on the largest line. Getting that last part wrong by a penny is easy, and invisible until a customer notices.

See [Pricing and discounts](/cartpresets/building/pricing) for the model itself.

## status

The derived status ladder, and what a rung means.

```js theme={null}
status.statusOf( preset );      // 'active' | 'scheduled' | 'inactive'
status.isLive( 'scheduled' );   // false
status.isPurchasable( preset );
```

Status is derived from the status switch, the dates and the caps every time it is read — never stored. Asking these rather than reading a field is what keeps your answer the same as the plugin's.

## format

Your store's own currency and date settings, already resolved.

```js theme={null}
format.money( 42.5 );                // in the store's currency, symbol position and separators
format.shortDate( '2026-09-10' );    // in the store's date format
```

The currency parts come from WooCommerce settings through the boot payload, so these match what the cart will print.

## The boot payload

Everything the panel is handed at load time is on `window.cartPresetsBoot`:

| Key            | Holds                                   |
| -------------- | --------------------------------------- |
| `restUrl`      | The REST base for `cartpresets/v1`      |
| `version`      | Plugin version                          |
| `now`          | The store's current time                |
| `currency`     | Symbol, position, decimals, separators  |
| `statuses`     | The derived status ladder               |
| `sorts`        | Valid sort keys                         |
| `filterFields` | The listing's filter grammar            |
| `settings`     | Resolved store settings                 |
| `links`        | URL parameter and permalink base        |
| `isPro`        | Which build is running                  |
| `upgradeUrl`   | Where the upgrade call to action points |
| `notices`      | The wording catalogue                   |

Add your own keys from PHP through [`cartpresets_admin_boot`](/cartpresets/developers/hooks-reference#the-admin-panel), and read them here without a second request.

```php theme={null}
add_filter( 'cartpresets_admin_boot', function ( $data ) {
	$data['myPlugin'] = array( 'enabled' => true );

	return $data;
} );
```

```js theme={null}
const mine = window.cartPresetsBoot.myPlugin;
```

<Warning>
  That filter is **additive only**. Removing or rewriting an existing key breaks the panel, and nothing downstream checks.
</Warning>

## No components are exported

An earlier version published a component library here. It no longer does.

The panel is transcribed from a design file rather than built on a component system, and its pieces are shaped by the screens they belong to rather than by being reusable. Publishing them would be promising an API that the next design round would break.

The helpers above are the stable part, because they answer to test fixtures rather than to a drawing.
