# Methods

`getLanguage()`

Returns the current language locale.

```
const locale = window.ZapietEats.getLanguage(); 
// Returns: "en"
```

`setLanguage(newLanguage)`

Sets the language for the widget.

```
window.ZapietEats.setLanguage('fr');
```

`getDeliveryOption()`

Returns the currently selected delivery option.

```
const option = window.ZapietEats.getDeliveryOption(); 
// Returns: "pickup" or "delivery"
```

\
​`setDeliveryOption(deliveryOption)`

Sets the delivery option.

1. `deliveryOption` (string): "pickup" or "delivery".

```
window.ZapietEats.setDeliveryOption('delivery');
```

`getSelectedRestaurant()`

Returns the currently selected restaurant object.

```
const restaurant = window.ZapietEats.getSelectedRestaurant();
```

`getSelectedMenu()`

Returns the currently selected menu object.

```
const menu = window.ZapietEats.getSelectedMenu();
```

`getSelectedDate()`

Returns the currently selected date as a ZapietDate object.

```
const date = window.ZapietEats.getSelectedDate();
```

`getLocationInventoryDate()`

Returns the date to be used for inventory checks, based on the selected location's timezone.

```
const inventoryDate = window.ZapietEats.getLocationInventoryDate();
// Returns: "YYYY-MM-DD"
```

`getSelectedTime()`

Returns the currently selected time as a ZapietTime object.

```
const time = window.ZapietEats.getSelectedTime();
```

`getSettings()`

Returns the account settings.

```
const settings = window.ZapietEats.getSettings();
```

`showTopBar()`

Shows the top bar of the widget.

```
window.ZapietEats.showTopBar();
```

`hideTopBar()`

Hides the top bar of the widget.

```
window.ZapietEats.hideTopBar();
```

`getZapietId()`

Generates the Zapiet ID string based on the current selection.

```
const zapietId = window.ZapietEats.getZapietId(); // Returns: "A=E&M=D&L=123&Z=456&D=2023-10-25&T=14:00"
```

`getAttributes()`

Returns an object containing the cart attributes based on the current selection.

```
const attributes = window.ZapietEats.getAttributes();
```

`addZapietId()`

Adds the Zapiet ID and attributes to the current cart.

```
window.ZapietEats.addZapietId().then((cart) => {
  console.log('Zapiet ID added to cart', cart);
});
```

\
​`getCartLineItemsWithZapietId(cart)`

Returns the cart items with the `_ZapietId` property added to them.

* `cart` (optional): The Shopify cart object. If not provided, it fetches the current cart.

```
window.ZapietEats.getCartLineItemsWithZapietId().then((items) => {
  console.log('Items with Zapiet ID', items);
});
```

`openModal()`

Opens the widget modal.

```
window.ZapietEats.openModal();
```

`closeModal()`

Closes the widget modal.

```
window.ZapietEats.closeModal();
```

`showMessage(data)`

Shows a message in the widget.

* `data` (object | string): The message data or string.
  * `message` (string): The message text.
  * `type` (string): "info" or "error".
  * `primaryAction` (object): Optional primary action button.
  * `secondaryAction` (object): Optional secondary action button.

```
window.ZapietEats.showMessage({
  message: 'Please select a location',
  type: 'error'
});
```

`closeMessage()`

Closes the currently displayed message.

```
window.ZapietEats.closeMessage();
```


---

# 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.zapiet.com/zapiet-eats/reference/methods.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.
