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 08-26-2013, 01:14 AM
TG Data Service's Avatar
TG Data Service is offline
 
Join Date: May 2013
Posts: 6
Question

Add element to the Cart page via Javascript


Hi,
I'm trying to add an element with javascript (basically i'm trying to add a custom button next to the checkout button) in the cart page. usually this works for other pages but this doesn't seem to work when i want to add the element in the table that the checkout button appears in on the cart page. I've been calling my addCustomBtn function within the OnPageLoaded but the element does not appear. However, if I add an element elsewhere in the page (for example I add a custom sub-title element) then it seems fine, it just seems to be that I can't add an element to the area that the checkout button appears in. Can anyone help me figure out why?

Ecwid.OnPageLoaded.add(function(page) {
if (page.type == 'CART') {
addCustomBtn();
}
});
  #2  
Old 08-26-2013, 09:38 AM
Eugene Rimmer's Avatar
Eugene Rimmer Eugene Rimmer is offline
Senior Member
 
Join Date: Jan 2011
Location: Ecwid headquarters
Posts: 7,765
Default

The trick is in the code of the addCustomBtn function you call. Do you have the code for it?
  #3  
Old 08-28-2013, 06:49 AM
TG Data Service's Avatar
TG Data Service TG Data Service is offline
 
Join Date: May 2013
Posts: 6
Default

I can actually see the button image appear for a hot second then it disappears

function addCustomBtn() {
elements = getElementsByClassName("ecwid-productBrowser-cart-checkoutButton");
if (elements.length == 1) {
checkoutBtn = elements[0];
para=document.createElement("div");
checkoutBtn.parentNode.insertBefore(para, checkoutBtn.parentNode.firstChild);
para.innerHTML = '<a href=\"ship\"><img src=\"newbutton.png\"/></a>';
}
}

Please help! Thanks!!!
  #4  
Old 08-28-2013, 10:11 AM
Eugene Rimmer's Avatar
Eugene Rimmer Eugene Rimmer is offline
Senior Member
 
Join Date: Jan 2011
Location: Ecwid headquarters
Posts: 7,765
Default

Quote:
Originally Posted by TG Data Service View Post
I can actually see the button image appear for a hot second then it disappears

function addCustomBtn() {
elements = getElementsByClassName("ecwid-productBrowser-cart-checkoutButton");
if (elements.length == 1) {
checkoutBtn = elements[0];
para=document.createElement("div");
checkoutBtn.parentNode.insertBefore(para, checkoutBtn.parentNode.firstChild);
para.innerHTML = '<a href=\"ship\"><img src=\"newbutton.png\"/></a>';
}
}

Please help! Thanks!!!
What is the URL address of the page where that happens?
  #5  
Old 09-02-2013, 12:52 AM
TG Data Service's Avatar
TG Data Service TG Data Service is offline
 
Join Date: May 2013
Posts: 6
Default

here it is
http://tgdataservice.com/cart#!/~/cart

to add something to the cart
tgdataservice.com/farmdata#!/~/product/category=5636612&id=23884705
 
The information in this thread might be outdated
If the solution did not help, please, check our Help Portal or contact Ecwid Team.

Tags
cart, custom, javascript

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 06:24 PM.
Powered by vBulletin® Version 3.8.11. Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.