# JavaScript

{% hint style="info" %}
**Developers only:** This documentation is intended for developers with technical knowledge and experience in Shopify Theme Development.
{% endhint %}

## Functions

<table data-full-width="false"><thead><tr><th>Geolocation popup</th><th>Market Selector Popup</th></tr></thead><tbody><tr><td><img src="/files/uRIrtHH3S8DLUpk55pPR" alt="" data-size="original"></td><td><img src="/files/nhSqbZI7WMREixQfWuuo" alt=""></td></tr><tr><td><code>md-app-embed__modal</code></td><td><code>md-app-embed__footer-popup</code></td></tr></tbody></table>

Use these JavaScript functions to manage popup behavior:

<table data-full-width="false"><thead><tr><th width="378">Function</th><th>Description</th></tr></thead><tbody><tr><td><code>orbito.openAndRefreshModal();</code></td><td>Opens the "Geolocation Popup" and automatically updates to match the user's current location and browser language preferences.</td></tr><tr><td><code>orbito.openModalWithoutRefresh();</code></td><td>Opens the "Geolocation Popup" but maintains the user's current selections within the Shopify storefront, avoiding any refresh.</td></tr><tr><td><code>orbito.openModal('md-app-embed__footer-popup');</code></td><td>Opens the "Market Selector" modal type.</td></tr><tr><td><code>orbito.closeModal('md-app-embed__modal');</code></td><td>Closes the "Geolocation Popup".</td></tr><tr><td><code>orbito.closeModal('md-app-embed__footer-popup');</code></td><td>Closes the "Market Selector" Popup</td></tr></tbody></table>

{% hint style="warning" %}
**Important notice**

To utilize these JavaScript functions effectively, ensure that the corresponding app embeds are enabled.
{% endhint %}

## Object

Orbe creates a JS object called `orbito` with both properties and methods to access geographical information about the user’s location.

#### Summary of `orbito` methods:

<table><thead><tr><th width="342">Method</th><th width="224">Description</th><th>Example output</th></tr></thead><tbody><tr><td><code>orbito.getRemoteCountryCode()</code></td><td>Country code based on the user location</td><td><code>GB</code>, <code>US</code></td></tr><tr><td><code>orbito.getRemoteRegionCode()</code></td><td>Region/state short code (FIPS or ISO format) directly based on the user location</td><td><code>CA</code> (For California in US), <code>MD</code> (For Madrid in Spain)</td></tr></tbody></table>

Here is an example of how to use the method `orbito.getRemoteCountryCode()`:

```javascript
var myCustomVar = '';
 setTimeout(() => {
   orbito.getRemoteCountryCode().then((value) => {
    myCustomVar = value;
    if (myCustomVar === 'GB') {
      console.log("User is in the UK");
    }
  });
}, 1000);
```

This code will log the message "User is in the UK" to the console only if the user is located in the United Kingdom, based on the `orbeCountryCode` object. You can modify the message to suit your needs and use this code as a starting point for implementing other customizations based on the user's location.

For instance, you could show a message on the product pages of users in the UK saying "2-hour delivery". Here's some sample code to achieve this:

```javascript
setTimeout(() => {
  orbito.getRemoteCountryCode().then((value) => {
    if (value === 'GB') {
      document.querySelector('.delivery-message').innerHTML = '2-hour delivery';
    } else if (value === 'US') {
      document.querySelector('.delivery-message').innerHTML = '1-day delivery';
    }
  });
}, 1000);
```

Note that you can adjust the delivery message based on the customer's country code, and the code above assumes you have a div element on your product pages with the class `.delivery-message` where you want to show the delivery message.

***

If you have any questions or need additional assistance, please don't hesitate to [contact us](https://orbe.app/contact).


---

# 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://help.orbe.app/developer-reference/javascript.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.
