You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Really stuck on what to do here as I keep getting the error 'uncaught fx error' whenever I try to get the live rates (hard coding the rates works fine).
/* ****************************************************************** *//* !CURRENCY CONVERTOR *//* ****************************************************************** */// Set up money.js currencies - get latest rates with ajax: $.getJSON('https://openexchangerates.org/api/latest.json?app_id=[my_app_id]',function(data){// Check money.js has finished loading:if(typeoffx!=="undefined"&&fx.rates){fx.rates=data.rates;fx.base=data.base;}else{// If not, apply to fxSetup global:varfxSetup={rates : data.rates,base : data.base}}});/* // Only hard-coding the rates like below works fx.base = "GBP"; fx.rates = { "EUR" : 1.41, // eg. 1 GBP === 1.41 EUR "GBP" : 1, // always include the base rate (1:1) "SEK" : 13.18, "DKK" : 10.55, "NOK" : 13.21, "USD" : 1.52, } */// Functions to convert prices on collection and product pagesfunctionosuConvertCurr(priceContainerParent,priceContainer,currencyContainer,activeCurrency){$(priceContainerParent).each(function(){varpriceToConvert=$(this).find(priceContainer).data('gbp-price');varpriceConverted=fx.convert(priceToConvert,{from: "GBP",to: activeCurrency});priceConverted=accounting.toFixed(priceConverted,0);$(this).find(priceContainer).text(priceConverted+' ');$(this).find(currencyContainer).text(activeCurrency);});}functionosuConvertCartItems(currency){// Convert each item$('.actual-price').each(function(){varitemPrice=$(this).text();varitemPriceConverted=fx.convert(itemPrice,{from: "GBP",to: currency});itemPriceConverted=accounting.toFixed(itemPriceConverted,0);$(this).text(itemPriceConverted+' ');$(this).next().text(currency);});}functionosuConvertCartCurr(currency){// Convert subtotalvarsubtotal=$('.cart-subtotal--price').text();varsubtotalConverted=fx.convert(subtotal,{from: "GBP",to: currency});subtotalConverted=accounting.toFixed(subtotalConverted,0);$('.cart-subtotal').find('.cart-subtotal--price').text(subtotalConverted+' ');$('.cart-subtotal').find('.product-currency').text(currency);}// Set correct dropdown state based on cookie valuevarcc_cookie=$.cookie('_cc_currency');if(cc_cookie=='USD'){$('.currency-convertor option[value=USD]').prop("selected","selected");}elseif(cc_cookie=='EUR'){$('.currency-convertor option[value=EUR]').prop("selected","selected");}elseif(cc_cookie=='SEK'){$('.currency-convertor option[value=SEK]').prop("selected","selected");}elseif(cc_cookie=='DKK'){$('.currency-convertor option[value=DKK]').prop("selected","selected");}elseif(cc_cookie=='NOK'){$('.currency-convertor option[value=NOK]').prop("selected","selected");}else{$('.currency-convertor option[value=GBP]').prop("selected","selected");}// Set cookie value based on dropdown$('.currency-convertor select').on('change',function(){varoptionValue=$(this).val();$.cookie('_cc_currency',optionValue,{expires: 14,path: '/'});location.reload();});// CONVERT CURRENCIES// --------------------------------------------------------------------if(cc_cookie!=='GBP'){// Collections and single productsif($('body').hasClass('template-collection')||$('body').hasClass('template-product')){osuConvertCurr('.product-price','.actual-price','.product-currency',cc_cookie);}// Cart pageif($('body').hasClass('template-cart')){osuConvertCartItems(cc_cookie);osuConvertCartCurr(cc_cookie);$('.cart-subtotal p').slideDown('medium');}}
Any ideas of what's going on?
Thanks,
Osu
The text was updated successfully, but these errors were encountered:
Really stuck on what to do here as I keep getting the error 'uncaught fx error' whenever I try to get the live rates (hard coding the rates works fine).
Here's the order I'm loading my scripts in:
And here's my jQuery code (myscript.js):
Any ideas of what's going on?
Thanks,
Osu
The text was updated successfully, but these errors were encountered: