Recharge redirect to checkout
var qs = (function(a) { if (a == "") return {}; var b = {}; for (var i = 0; i < a.length; ++i) { var p=a[i].split('=', 2); if (p.length == 1) b[p[0]] = ""; else b[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " ")); } return b; })(window.location.search.substr(1).split('&')); if(qs['redirect'] == 'checkout'){ reChargeProcessCart() } function reChargeProcessCart() { var subscription = false; fetch(window.Shopify.routes.root + 'cart.js') .then(response => response.json()) .then(data => { data.items.forEach(x=>{ console.log(x) if(x.properties){ if(x.properties.hasOwnProperty('shipping_interval_frequency')){ subscription = true; return; } } }) function get_cookie(name){ return( document.cookie.match('(^|; )'+name+'=([^;]*)')||0 )[2] } if(subscription){ do { token=get_cookie('cart'); } while(token == undefined); var myshopify_domain='{{ shop.permanent_domain }}' try { var ga_linker = ga.getAll()[0].get('linkerParam') } catch(err) { var ga_linker ='' } checkout_url= "https://checkout.rechargeapps.com/r/checkout?myshopify_domain="+myshopify_domain+"&cart_token="+token+"&"+ga_linker; window.location.href = checkout_url }else{ window.location.href = '/checkout' } console.log(subscription) }); }