JavaScript

Use Orbe's variables and functions for your custom localization needs

Developers only: This documentation is intended for developers with technical knowledge and experience in Shopify Theme Development.

Functions

Geolocation popup
Market Selector Popup

md-app-embed__modal

md-app-embed__footer-popup

Use these JavaScript functions to manage popup behavior:

Function
Description

orbito.openAndRefreshModal();

Opens the "Geolocation Popup" and automatically updates to match the user's current location and browser language preferences.

orbito.openModalWithoutRefresh();

Opens the "Geolocation Popup" but maintains the user's current selections within the Shopify storefront, avoiding any refresh.

orbitoMK.openModal('md-app-embed__footer-popup');

Opens the "Market Selector" modal type.

orbito.closeModal('md-app-embed__modal');

Closes the "Geolocation Popup".

orbitoMK.closeModal('md-app-embed__footer-popup');

Closes the "Market Selector" Popup

Important notice

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

The "Geolocation Popup" should be activated for using orbito related functions, and the "Market Selector" should be enabled for orbitoMK functions.

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:

Method
Description
Example output

orbito.getRemoteCountryCode()

Country code based on the user location

GB, US

orbito.getRemoteRegionCode()

Region/state short code (FIPS or ISO format) directly based on the user location

CA (For California in US), MD (For Madrid in Spain)

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

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:

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.

Last updated