Orbe – Help center
PlansPartnersUse CasesSupportChangelog
  • 👋Before starting
    • Welcome
    • How Orbe works
    • Pricing
    • FAQs
  • 🧩GENERAL
    • Install Orbe
    • Refresh Data
    • Connect Stores
      • Redirect to another store
      • Settings
    • Integrations
      • Klaviyo
      • Global-e
      • Connectif
      • Hreflang Manager
      • Announcement Bar
    • Uninstall Orbe
  • 🌐Geolocation Popup
    • Set up Geolocation
    • Translations
    • Common issues
  • 🔁Selectors
    • Overview
    • Geolocation Button
      • How it works
      • Selector Placement
      • Variables
      • Custom Code
    • Market Selector
  • ⚙️Settings
    • Notifications
    • Behavioral Preferences
    • Custom CSS
  • Developer Reference
    • CSS
    • JavaScript
    • Relocating the Market Selector
    • Integrate your selector
    • Snippets
      • Create a full-screen popup
      • Country Order Customization
      • Language Order Customization
      • Hide the popup in a country
      • Change popup fonts
      • Hide countries
Powered by GitBook
On this page
  • Geolocation Popup
  • CSS
  • JavaScript
  • Popup Selector

Was this helpful?

  1. Developer Reference
  2. Snippets

Country Order Customization

Country Order Customization in Orbe's Selector

PreviousCreate a full-screen popupNextLanguage Order Customization

Last updated 4 months ago

Was this helpful?

Geolocation Popup

In Orbe, the country list within the selector is alphabetically ordered by default. However, it's possible to customize this order using CSS, allowing you to prioritize certain countries by placing them at the top of the list.

For example, in this country selector, you can see that the United States and the United Kingdom are at the top when you open the selector:

Here's a step-by-step guide on how to achieve this through Custom CSS:

Step 1: Modify the Display of the List

To start, we need to change the display setting of the country list to a grid layout. This allows us to reorder the countries:

.md-form__select__country__list {
    display: grid;
}

.md-form__select__country__list[hidden] {
    display: none;
}

Step 2: Set Default Order

Next, set a default order for all countries in the list. This ensures that any country not explicitly reordered will follow this default setting:

.md-form__select__country__list li {
    order: 2;
}

Step 3: Reorder Specific Countries

Now, you can select specific countries and assign them a different order. In this example, we're moving the United States (US) and the United Kingdom (GB) to the top of the list:

.md-form__select__country__list li[data-country="US"], .md-form__select__country__list li[data-country="GB"]{
    order: 1;
}

By adding these CSS classes, you can easily customize the order of countries within the Orbe selector.

CSS

Here's the complete CSS snippet for repositioning the United States and the United Kingdom at the top of the list:

.md-form__select__country__list {
    display: grid;
}

.md-form__select__country__list[hidden] {
    display: none;
}

.md-form__select__country__list li {
    order: 3;
}

.md-form__select__country__list li[data-country="US"] {
    order: 1;
}
.md-form__select__country__list li[data-country="GB"] {
    order: 2;
}

With this customization, you can enhance the user experience by highlighting the most relevant countries for your business.

JavaScript

You can also achieve this by using this JavaScript code and adding it to your theme code:

document.addEventListener("DOMContentLoaded", function() {
    setTimeout(function() {
        const countryList = document.querySelector("#orbeCountryList");
        const priorityCountries = ["US", "GB"];
        // Loop through each country in reverse order and move it to the top
        priorityCountries.reverse().forEach(countryCode => {
            const countryItem = countryList.querySelector(`li[data-country="${countryCode}"]`);
            if (countryItem) {
                countryList.insertBefore(countryItem, countryList.firstChild);
            }
        });
    }, 1000);
});

Popup Selector

In Orbe's Market Selector Popup, you can customize the country order using CSS.

Unlike the Geolocation Popup, the parent container already uses a grid display by default, so you only need to adjust the order of the individual items.

Set all items to a default order and prioritize the desired countries:

.md-modal__footer-selector-modal__region-list-item {
    order: 3;
}

.md-modal__footer-selector-modal__region-list-item[data-country="FR"] {
    order: 1;
}

.md-modal__footer-selector-modal__region-list-item[data-country="ES"] {
    order: 2;
}

In this example:

  • France (FR) appears first.

  • Spain (ES) appears second.

  • All other countries are shown below.

Simply replace "GB" and "US" with the country codes of your preferred countries to tailor the list to your needs. This refers to the ISO two-letter code (alpha-2) of the country. You can find the global list of country ISO two-letter codes at .

Replace the country codes (ES, FR) with your preferred ISO alpha-2 codes as needed. You can find the global list of country ISO two-letter codes at .

https://countrycode.org/
https://countrycode.org/