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 popupMarket Selector Popup

md-app-embed__modal

md-app-embed__footer-popup

Use these JavaScript functions to manage popup behavior:

FunctionDescription

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.

Variables

Orbe creates a JS variable called orbeCountryCode and access it with mdApp_orbeCountryCode function, which allows developers to access the country where the customer is located based on their IP address. This object returns the country code where the customer is browsing, which can be used to customize the theme further.

Here is an example of how to use this object:

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