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 03-30-2012, 06:50 PM
alfalfa's Avatar
alfalfa is offline
 
Join Date: Feb 2012
Posts: 16
Default

Integrate text + Javascrip code


Hi!

I would like to show specific texts for shipping on checkout page + use this kind of script :

HTML Code:
<script type="text/javascript">
Ecwid.OnPageLoaded.add(function(page) {
    if (page.type == "PRODUCT") {       jQuery("div.ecwid-productBrowser-details-GalleryPanel").insertAfter(".ecwid-productBrowser-details-thumbnail");
    }
})
</script>
This is my final html :

HTML Code:
<div>


<script type="text/javascript">
Ecwid.OnPageLoaded.add(function(page) {
if (page.type == "PRODUCT") { jQuery("div.ecwid-productBrowser-details-descr").insertAfter(".ecwid-productBrowser-price");
}
})
</script>
<noscript>Your browser does not support JavaScript. Please proceed to <a href="http://app.ecwid.com/jsp/1045450/catalog">HTML version of guillaume boucher's store</a></noscript>

<script type="text/javascript">
Ecwid.OnPageLoaded.add(function(page) {
    if (page.type == "PRODUCT") {       jQuery("div.ecwid-productBrowser-details-GalleryPanel").insertAfter(".ecwid-productBrowser-details-thumbnail");
    }
})
</script>

 <script type="text/javascript">
        


        var last_hash = '';

function poll_hash() {
    if(last_hash !== document.location.hash) {
        last_hash = document.location.hash;
        add_cart_text(last_hash);    
    }
}


function add_cart_text(hash) {
    var cart_text = document.getElementById('cart-text');
    if (cart_text) {
    if (hash.indexOf('mode=cart') == -1) {
        cart_text.style.display = 'none';
    } else {
        cart_text.style.display = '';
    }
    }
}

setInterval(poll_hash, 100);




</script>


<div id="cart-text" style="display:none;"><h3>Whoo-hoo! We're on the cart page.</h3> </div>

<script type="text/javascript" src="http://app.ecwid.com/script.js?1045450" charset="utf-8"></script>
<script type="text/javascript"> xProductBrowser("categoriesPerRow=3","views=grid(3,3) list(10) table(20)","categoryView=grid","searchView=list","style="); </script>
</div>
the insertAfter work well but unfortunatly th <h3> never appear... Please need help
  #2  
Old 04-05-2012, 02:10 PM
Eugene Rimmer's Avatar
Eugene Rimmer Eugene Rimmer is offline
Senior Member
 
Join Date: Jan 2011
Location: Ecwid headquarters
Posts: 7,765
Default

First of all, Ecwid.OnPageLoaded is an object, provided by Ecwid's main script, so you should have this line:
Code:
<script type="text/javascript" src="http://app.ecwid.com/script.js?1045450" charset="utf-8"></script>
before any script that uses such objects.

The poll_hash is and the whole store with it is a deprecated code, you simply don't need that now with the Ecwid.OnnPageLoad/ed. That obsolete code should be reworked.

Eventually, after all these changes, the code you provided shrinks into as little as this:
Code:
<script type="text/javascript" src="http://app.ecwid.com/script.js?1045450" charset="utf-8"></script>
<script type="text/javascript">
Ecwid.OnPageLoaded.add(function(page) {
	var $ = window.jQuery;
	if (page.type == "PRODUCT") { 
		$("div.ecwid-productBrowser-details-descr").insertAfter(".ecwid-productBrowser-price");
    	$("div.ecwid-productBrowser-details-GalleryPanel").insertAfter(".ecwid-productBrowser-details-thumbnail");
	}
	$('#cart-text').toggle(page.type == "CART")
})
</script>
<div id="cart-text" style="display:none;"><h3>Whoo-hoo! We're on the cart page.</h3> </div>
<script type="text/javascript"> xProductBrowser("categoriesPerRow=3","views=grid(3,3) list(10) table(20)","categoryView=grid","searchView=list","style="); </script>
</div>

Last edited by Eugene Rimmer; 04-05-2012 at 04:46 PM.
The Following User Says Thank You to Eugene Rimmer For This Useful Post:
alfalfa (04-05-2012)
  #3  
Old 04-05-2012, 05:14 PM
alfalfa's Avatar
alfalfa alfalfa is offline
 
Join Date: Feb 2012
Posts: 16
Default

Thank you it works well!
  #4  
Old 04-08-2012, 05:53 PM
alfalfa's Avatar
alfalfa alfalfa is offline
 
Join Date: Feb 2012
Posts: 16
Default

Hi,

It seems like I'm doing wrong to specify text for specific category

HTML Code:
<script src="http://app.ecwid.com/script.js?1045450" type="text/javascript"></script>
 <script type="text/javascript">// <![CDATA[
Ecwid.OnPageLoaded.add(function(page) {
	var $ = window.jQuery;
	if (page.type == "PRODUCT") { 
		$("div.ecwid-productBrowser-details-descr").insertAfter(".ecwid-productBrowser-price");
    	$("div.ecwid-productBrowser-details-GalleryPanel").insertAfter(".ecwid-productBrowser-details-thumbnail");
	}
	$('#cart-text').toggle(page.type == "CATEGORY=2308117")
})
// ]]></script>
<div id="cart-text" style="display: none;">
<h3>Whoo-hoo! We're on the cart page.</h3>
&nbsp;

</div>
<script type="text/javascript">// <![CDATA[
 xProductBrowser("categoriesPerRow=3","views=grid(3,3) list(10) table(20)","categoryView=grid","searchView=list","style="); 
// ]]></script>

http://alfalfanewyork.com/test3#ecwi...=addedTimeDesc
  #5  
Old 04-08-2012, 06:29 PM
alfalfa's Avatar
alfalfa alfalfa is offline
 
Join Date: Feb 2012
Posts: 16
Default

I found my error...

the corrected code here :

HTML Code:
<script src="http://app.ecwid.com/script.js?1045450" type="text/javascript"></script>
 <script type="text/javascript">// <![CDATA[
Ecwid.OnPageLoaded.add(function(page) {
	var $ = window.jQuery;
	if (page.type == "PRODUCT") { 
		$("div.ecwid-productBrowser-details-descr").insertAfter(".ecwid-productBrowser-price");
    	$("div.ecwid-productBrowser-details-GalleryPanel").insertAfter(".ecwid-productBrowser-details-thumbnail");
	}
	$('#cart-text').toggle(page.categoryId == "2308117")
})
// ]]></script>
<div id="cart-text" style="display: none;">
<h3>Whoo-hoo! We're on the cart page.</h3>
&nbsp;

</div>
<script type="text/javascript">// <![CDATA[
 xProductBrowser("categoriesPerRow=3","views=grid(3,3) list(10) table(20)","categoryView=grid","searchView=list","style="); 
// ]]></script>
 
The information in this thread might be outdated
If the solution did not help, please, check our Help Portal or contact Ecwid Team.

Tags
html, insert, 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 02:35 AM.
Powered by vBulletin® Version 3.8.11. Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.