");
const handle = "product4exchangerates";
const countryCode = "LB";
const ccEnum = String(countryCode || "US").replace(/[^A-Z]/g, "").toUpperCase();
if (!/^[A-Z]{2}$/.test(ccEnum)) throw new Error("Invalid country code: " + countryCode);
const query = `
query ProductByHandle @inContext(country: ${ccEnum}) {
product(handle: "${handle}") {
variants(first: 1) {
nodes {
id
price { amount currencyCode }
compareAtPrice { amount currencyCode }
}
}
}
}`;
const res = await fetch("/api/2024-10/graphql.json", {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-Shopify-Storefront-Access-Token": window.STOREFRONT_TOKEN
},
body: JSON.stringify({ query })
});
if (!res.ok) throw new Error(`Storefront API HTTP ${res.status}`);
const { data, errors } = await res.json();
if (errors) throw new Error(`GraphQL errors: ${JSON.stringify(errors)}`);
const v = data?.product?.variants?.nodes?.[0];
if (!v) throw new Error("No variant found for handle: " + handle);
//return { price: v.price, compareAtPrice: v.compareAtPrice };
const price = formatMoneyV2(v.price);
const compareAt = v.compareAtPrice ? formatMoneyV2(v.compareAtPrice) : null;
console.log(compareAt);
if (compareAt && Number(data.compareAtPrice.amount) > Number(data.price.amount)) {
$("span.announcement__text #LrFreeShipPrice").html(compareAt);
}
}
console.log("---------------------->");
document.addEventListener("DOMContentLoaded", adjustFreeShippingPrice);
*/
var hostext = window.location.hostname.replace(/(.*)\.([a-z]{2,3})/i, '$2');
$("ul.site-nav ul.site-nav__dropdown a, ul.mobile-nav ul.mobile-nav__sublist a").each(function() {
if ($(this).attr('href').match(/https?:\/\/(www\.)?lonerider(-motorcycle)?\.[a-z]{2,3}\/?/i)) {
$(this).attr('data-ln', $(this).attr('href').replace(/(.*)\.([a-z]{2,3})\/?/i, '$2')).click(function(event) {
event.preventDefault();
window.location.href = LR.redirect($(this).attr('data-ln'), 'LBP', true);
});
/* var pth = window.location.pathname
console.log("1------->"+pth+" ---> "+ $(this).attr('data-ln'))
if ($(this).attr('data-ln') != 'com' && pth.match(/^\/[a-z]{2}-[a-z]{2}\/?/i)) {
pth = pth.replace(/^\/[a-z]{2}-[a-z]{2}\/?/i, '/')
}
console.log("2------->"+pth+" ---> "+ $(this).attr('data-ln'))*/
var pth = window.location.pathname.replace(/^\/[a-z]{2}-[a-z]{2}(\/|$)/i, '/')
$(this).attr('href', $(this).attr('href')+pth.substr(1));
}
});
$('#Linklist-currency a, #currency_picker a').each(function(elem) {
$(this).attr('data-cur', $(this).attr('href').substr(-3)).click(function(event) {
window.location.href = LR.redirect(hostext, $(this).attr('data-cur'), true);
event.preventDefault();
});
$(this).attr('href', '#');
});
/*if ($("span.announcement__text").html().trim().substr(0, 12) == freestr1.trim().substr(0, 12)) {
var country = LR.GetCookie('LR_FREE_SHIPPING_COUNTRY');
if (country == undefined || country.length<2) {
var jqxhr = $.get( "//file.lonerider-motorcycle.com/ip.php").done(function(ip) {
jqxhr = $.get( "https://ip2c.org/?ip="+ip).done(function(country_ip) {
country = country_ip.replace(/;/g, '|');
LR.SetCookie('LR_FREE_SHIPPING_COUNTRY', country, 1);
LR_set_free_shipping(country)
});
});
}
else {
LR_set_free_shipping(country)
}
}*/
country_set(country);
//$("#KFooterNewsletterForm").after('');
};
if (LR.bot()) {
document.getElementById("announcement_top_bar").style.display = "none";
}
else {
if ((typeof jQuery === 'undefined') || (parseFloat(jQuery.fn.jquery) < 1.7)) {
LRloadScript('//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js', function(){
jQuery191 = jQuery.noConflict(true);
LRAppJavaScript(jQuery191);
});
} else {
LRAppJavaScript(jQuery);
}
}