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

# Functions available in the core of CoCart

> Extend support for CoCart with these useful functions in your projects

## `cocart_maybe_show_results()`

Checks if the session table exists before returning results. Helps prevents any fatal errors or crashes should debug mode be enabled.

**Returns**: `boolean Returns true or false if the session table exists.`

* **Since**: 4.2.0 Introduced.
* **Defined in**: [`includes/cocart-core-functions.php`](https://github.com/co-cart/co-cart/blob/development/includes/cocart-core-functions.php#L112)

***

## `cocart_count_carts_expiring()`

Counts how many carts are going to expire within the next 6 hours.

**Returns**: `int Number of carts expiring.`

* **Since**: 4.2.0 Introduced.
* **Defined in**: [`includes/cocart-core-functions.php`](https://github.com/co-cart/co-cart/blob/development/includes/cocart-core-functions.php#L168)

***

## `cocart_count_carts_active()`

Counts how many carts are active.

**Returns**: `int Number of carts active.`

* **Since**: 4.2.0 Introduced.
* **Defined in**: [`includes/cocart-core-functions.php`](https://github.com/co-cart/co-cart/blob/development/includes/cocart-core-functions.php#L199)

***

## `cocart_count_carts_expired()`

Counts how many carts have expired.

**Returns**: `int Number of carts expired.`

* **Since**: 4.2.0 Introduced.
* **Defined in**: [`includes/cocart-core-functions.php`](https://github.com/co-cart/co-cart/blob/development/includes/cocart-core-functions.php#L229)

***

## `cocart_carts_source_web()`

Counts how many carts were created via the web.

**Returns**: `int Number of carts created via the web.`

* **Since**: 4.2.0 Introduced.
* **Defined in**: [`includes/cocart-core-functions.php`](https://github.com/co-cart/co-cart/blob/development/includes/cocart-core-functions.php#L259)

***

## `cocart_carts_source_headless()`

Counts how many carts were created via CoCart API.

**Returns**: `int Number of carts created via CoCart API.`

* **Since**: 4.2.0 Introduced.
* **Defined in**: [`includes/cocart-core-functions.php`](https://github.com/co-cart/co-cart/blob/development/includes/cocart-core-functions.php#L289)

***

## `cocart_carts_source_other()`

Counts how many carts were the source is other or unknown.

**Returns**: `int Number of carts created via other or unknown.`

* **Since**: 4.2.0 Introduced.
* **Defined in**: [`includes/cocart-core-functions.php`](https://github.com/co-cart/co-cart/blob/development/includes/cocart-core-functions.php#L319)

***

## `cocart_get_min_max_price_meta_query()`

Get min/max price meta query args.

| Parameter | Type    | Description                        |
| --------- | ------- | ---------------------------------- |
| `$args`   | `array` | Min price and max price arguments. |

**Returns**: `array`

* **Since**: 3.4.1 Introduced.
* **Defined in**: [`includes/cocart-rest-functions.php`](https://github.com/co-cart/co-cart/blob/development/includes/cocart-rest-functions.php#L506)

***

## `cocart_get_frontend_url()`

Get the frontend URL.

| Parameter   | Type    | Description                               |
| ----------- | ------- | ----------------------------------------- |
| `$settings` | `array` | CoCart settings passed. Empty by default. |

**Returns**: `string`

* **Since**: 5.0.0 Introduced.
* **Defined in**: [`includes/cocart-rest-functions.php`](https://github.com/co-cart/co-cart/blob/development/includes/cocart-rest-functions.php#L633)

***

## `cocart_is_wp_disabled_access()`

Checks if WordPress has been disabled access.

| Parameter   | Type    | Description                              |
| ----------- | ------- | ---------------------------------------- |
| `$settings` | `array` | CoCart settings passed. Default is 'no'. |

**Returns**: `string`

* **Since**: 5.0.0 Introduced.
* **Defined in**: [`includes/cocart-rest-functions.php`](https://github.com/co-cart/co-cart/blob/development/includes/cocart-rest-functions.php#L667)

***

## `cocart_get_permalink()`

Returns the permalink for a page/post/product and replaces the frontend URL if set.

| Parameter   | Type     | Description                               |
| ----------- | -------- | ----------------------------------------- |
| `$url`      | `string` | Permalink of page/post/product.           |
| `$settings` | `array`  | CoCart settings passed. Empty by default. |

**Returns**: `string Permalink.`

* **Since**: 5.0.0 Introduced.
* **Defined in**: [`includes/cocart-rest-functions.php`](https://github.com/co-cart/co-cart/blob/development/includes/cocart-rest-functions.php#L697)

***
