# JS Events

This document outlines the JavaScript events used in minicart.js and custom.js. These events help manage cart interactions, updates, and notifications within the shopping experience.

**Events in minicart.js**

`carttotalitems`

* Description: This event is triggered to update the total number of items in the cart.
* When: After retrieving the cart data in the getCart method.
* Data: The number of items in the cart.

`cartupdated‍`

* This event is triggered to indicate that the cart has been updated.
* When: After successfully updating the item quantity in the cart in the updateCartItemQuantity method.
* Data: No additional data.

`showcartmessage`

* Description: This event is triggered to display a message in the cart.
* When: After successfully or unsuccessfully updating the item quantity in the updateCartItemQuantity method.
* Data: An object containing status, message, and description.

`currentcartitems`

* Description: This event is triggered to transmit the current items in the cart.
* When: After retrieving the cart data in the returnCartItems method.
* Data: An array of the current cart items (this.cart.items).

**Events in custom.js**

`cartupdated‍`

* Description: This event is triggered to indicate that the cart has been updated.
* When: After adding products to the cart in the methods addToCartWithBundle, addToCart, and addGlobalBundleToCart.
* Data: The current products in the cart (this.products).

`toggleminicart`

* Description: This event is triggered to show or hide the mini cart.
* When: After adding products to the cart in the methods addToCartWithBundle and addGlobalBundleToCart.
* Data: No additional data.

`showcartmessage`

* Description: This event is triggered to display a message in the cart.
* When: After adding products to the cart in the methods addToCartWithBundle, addToCart, addGlobalBundleToCart, and in case of errors in these methods.
* Data: An object containing status, message, and description.


---

# 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.liquiflow.app/liquid-attributes/js-events.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.
