Thread: Javascript API
View Single Post
  #1  
Old 06-10-2014, 07:06 PM
Kevin Kraus's Avatar
Kevin Kraus Kevin Kraus is offline
 
Join Date: Oct 2013
Posts: 1
Default Javascript API

Store ID 2673243 https://www.401k-checkup.com/portfolio-request-form/Short version: The callbacks are not firing on the initial pageload. It worked for weeks as we refined our JS code and we tested thoroughly. It stopped working in the past week as the initial pageloads quit firing. The onpage load and onpage loaded initial firing of the messages is no longer happening.

More detail: Our goal was to:
1) CLEAR our cart.
2) ADD a single product to the cart.
3) Display the shopping bag.
4) Optionally display the cart bypassing the shopping bag.


<center>[php function=3]</center>
<script type='text/javascript' src='https://www.401k-checkup.com/wp-includes/js/401k.js'></script>
<center><h1>Thank You, your checkout is being processed.</h1></center>
<script type="text/javascript" src="https://app.ecwid.com/script.js?2673243" charset="utf-8"></script>
<script src="https://app.ecwid.com/script.js?1003" type="text/javascript" charset="UTF-8"></script>
<script type="text/javascript">
ecwidMessages = {
"PaymentDetails.enter_email" : "Confirm your email and press the Continue button below."
};
</script>
<script type="text/javascript">
function f(){
f.count = ++f.count || 1
}
function g(){
g.count = ++g.count || 1
}
Ecwid.OnPageLoad.add(function(page) {
f();
if(f.count==1) {
Ecwid.Cart.clear();
var shdata = document.getElementById('sel').innerHTML;
if(shdata=='ADVANCED SCAN Checkup A (3, 5 &amp; 10 year report; components w/o data excluded from scan) $75') {
pnum=28869606;
}
if(shdata=='ADVANCED SCAN Checkup B (1, 3 &amp; 5 year report; components w/o data excluded from scan) $75')
{
pnum=28869607;
}
if(shdata=='QUICK SCAN Checkup, 1 year (components w/o data excluded from scan) $30')
{
pnum=28869551;
}
if(shdata=='QUICK SCAN Checkup, 3 year (components w/o data excluded from scan) $30')
{
pnum=28869592;
}
if(shdata=='QUICK SCAN Checkup, 5 year (components w/o data excluded from scan) $30')
{
pnum=28869604;
}
if(shdata=='QUICK SCAN Checkup, 10 year (components w/o data excluded from scan) $30')
{
pnum=28869605;
}
alert(pnum);
Ecwid.Cart.addProduct(pnum, function(success, product, cart){
console.log(success); // true or false
console.log(product.name);
window.location = 'https://www.401k-checkup.com/portfolio-request-form-confirmation/#!/~/cart';
});
}
});
Ecwid.OnPageLoaded.add(function(page) {
g();
if(g.count>=2) {
var e=document.getElementById('eaddr').innerHTML;
document.getElementById('gwt-uid-26').value=e;
}
});
</script>