Aurora $.international jQuery Library

Overview

This is a JavaScript library provided by Aurora Commerce on an "as is" basis that demonstrates how to perform certain operations within an international multi-host environment.

To use the Aurora $.international jQuery Library:

  • Upload the $.frontend and $.international library files to: 

    templates/yoursite.com/_js/aurora_frontend.js
    templates/yoursite.com/_js/aurora_international.js
    
  • Add the following to your header template:

    {include_js resource_url_prefix=$resource_url_prefix files=aurora_frontend,aurora_international}
    

🚧

This library and all its methods are provided for convenience of use and reference only and are not supported by Aurora Commerce or developed as standard practice as this falls outside the general remit of 'development work' now adhered to, as described in the Design vs Development Guidelines.

If functionality that is not provided by this library is required, then it is the responsibility of the Agencies to perform any work necessary to add said functionality.

Glossary of Terms

Before we begin, please see the following list of terms used in this document (and throughout the Aurora documentation) to describe different aspects of Aurora and it's systems:

  • Aurora Core: This refers to anything that is common to ALL instances of Aurora and belongs to Aurora Commerce. This includes anything in the Back-end and most scripts driving the Front-end (not the Front-end templates).
  • Aurora Demo: This refers to the globally accessible demonstration website that Aurora Commerce provide and can be found here: https://demo.auroracommerce.com/
  • Back-end: This refers to the administration area of Aurora, which is any Page, Code or System found in or controlled by the "/aurora/" section of your site.
  • Front-end: This refers to the customer facing area of your website, i.e. the website in general, which your customers can see.
  • Templates: These are files (usually HTML, but can also include some images, JavaScript and CSS) that control how your site looks and is structured. Back-end Templates refer to the 'look' of the pages in the '/aurora/' section and belong editing wise to Aurora Commerce while Front-end templates refer to the 'look' of the main customer facing website and editing wise belong to you and your Agency.

Check User Country

This feature relies on features and interfaces within Aurora 3.4+

To initialise a user country check on all pages, add the following to your header template:

{**
 * Define multilingual messages 
 *}

{capture assign="hs_message"}{site_text page="Global" part="Text: Host Selector Message" default="You appear to be in a different country, which site are you looking for?"}{/capture}

{capture assign="hs_es"}{site_text page="Global" part="Text: Host Selector Spain" default="Stay on Spanish Site"}{/capture}

{capture assign="hs_fr"}{site_text page="Global" part="Text: Host Selector France" default="Go to French Site"}{/capture}

{capture assign="hs_uk"}{site_text page="Global" part="Text: Host Selector UK" default="Go to UK Site"}{/capture}

{**
 * Trigger a user country check with "es" (Spain) as the default country code
 *}

<script type="text/javascript">{literal}
$(document).on('ready', function(e) {
   $.international.check_user_country('{/literal}{$default_country_iso2}{literal}', {
      host_selector_message: '{/literal}{$hs_message}{literal}',
      host_selector_hosts: [
         {
            code: 'es',
            name: '{/literal}{$hs_es}{literal}',
            domain: 'www.yoursite.es'
         },
         {
            code: 'fr',
            name: '{/literal}{$hs_fr}{literal}',
            domain: 'www.yoursite.fr'
         },
         {
            code: 'gb',
            name: '{/literal}{$hs_uk}{literal}',
            domain: 'www.yoursite.co.uk'
         }
      ]
   });
});
{/literal}</script>

This will result in a popup dialog being displayed to a user when their IP address is successfully resolved to a country other than the supplied default country code i.e.

1020

🚧

The default country code passed to the check_user_country function must match the ISO2 code as defined within the Aurora default country; please see Maintaining Countries

Aurora exposes the default country ISO2 value to all front-end templates using the $default_country_iso2 template variable.

The current URL is used to build a deep link to all supplied host domains; the HTML rendered is as follows and can be styled accordingly:

<div class="international_host_selector">
	<span>You appear to be in a different country, which site are you looking for?</span>
	<ul>
		<li><a href="#" class="set_users_default_country">Stay on Spanish Site</a></li>
		<li><a href="http://www.yoursite.fr/clothes">Got to French Site</a></li>
		<li><a href="http://www.yoursite.co.uk/clothes">Go to UK Site</a></li>
	</ul>
</div>

Get User Country Code

To get the current users country code as identified by Aurora, use the following interface:

<script type="text/javascript">
var country_code = $.international.get_user_country_code();
</script>

Downloads

aurora_international.js