Skip to content

Instantly share code, notes, and snippets.

@AdamSwinden
Created May 1, 2018 15:12
Show Gist options
  • Save AdamSwinden/ae108ac33fa1b971850872335c2aed51 to your computer and use it in GitHub Desktop.
Save AdamSwinden/ae108ac33fa1b971850872335c2aed51 to your computer and use it in GitHub Desktop.
/**
* Set Store Currency
*/
function setStoreCurrency(globalCurrency) {
var currencySetUkButton = $( '.currencySetUk' ),
currencySetEuButton = $( '.currencySetEu' ),
currencySetUsButton = $( '.currencySetUs' ),
body = $( 'body' );
// Set to local Storage value
if (globalCurrency) {
var currencyClass = 'currency-' + globalCurrency;
body.addClass(currencyClass);
}
currencySetUkButton.click( function() {
if ( !currencySetUkButton.hasClass('js-currency-toggle') ) {
$('.m1-header__currency-button--active').removeClass('m1-header__currency-button--active');
currencySetUkButton.addClass('m1-header__currency-button--active');
body.addClass('currency-uk');
tomEraseCookie('globalCurrency');
tomCreateCookie('globalCurrency', 'uk', 7);
location.reload();
}
});
// Continue for Each Store/Currency
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment