<form action="/checkout" style="display: none;">
<a href="/checkout" name="checkout" style="display: none;"></a>
</form>
<button id="buy_now_button">BUY NOW</button>
var buyNow = document.getElementById('buy_now_button');
buyNow && buyNow.addEventListener('click', function (evt) {
evt.preventDefault();
$.get("http://ipinfo.io", function (response) {
if (response.country == "US") {
//Send to CartHook
window.testGlobalBeforeReact(0);
}
else if (response.country != "US") {
//Send to Shopify
window.location.href ='/checkout';
}
}, "jsonp");
});