The information in this thread might be outdated
If the solution did not help, please, check our Help Portal or contact Ecwid Team.
 
 
Thread Tools Display Modes
  #1  
Old 06-10-2014, 07:06 PM
Kevin Kraus's Avatar
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>
  #2  
Old 06-16-2014, 08:00 PM
Viktor D.'s Avatar
Viktor D. Viktor D. is offline
 
Join Date: Nov 2013
Posts: 720
Default

Dear Kevin, thank you very much for your message.

I've checked the code on your cart page.

Event Ecwid.OnPageLoad.add() will work only for Ecwid Product browser widget. So the solution is pretty simple, not to use 'OnPageLoad', in your case.

Please, do not hesitate to ask any questions.
 
The information in this thread might be outdated
If the solution did not help, please, check our Help Portal or contact Ecwid Team.

Tags
add to bag, cart display, javascript api

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:17 PM.
Powered by vBulletin® Version 3.8.11. Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.