If you have a Dynamicweb Web soloution with eCommerce you may want to inform the visitor/customer about the number of products in the basket. One logical place to add this information would be on the PAGE template - and yes, it's that simpel!
A very simpel example would be to add:
In basket: <!--@Ecom:Order.OrderLines.TotalQuantity-->
products
Unfortunally if there is nothing in the basket Dynamicweb will just leave the tag unpassed, so your HTML code will not contain "0" if nothing is in the basket.
To solve this situation you will need to write some javascript. I Suggest that you put the basket information inside - say - a DIV with a specifik ID ("GlobalBasket" for instance) and then set the CSS Display to "none". The javascript code should then toggle the CSS Display attribute if nessesary.
Here is a simple example:
<div id="GlobalBasket" style="display: none">
<b>In basket: <!--@Ecom:Order.OrderLines.TotalQuantity--> products</b>
</div>
<div id="GlobalBasketEmpty" style="display: none">
<b>Basket is empty</b>
</div>
<script type="text/javascript">
var iQuantity = parseInt('<!--@Ecom:Order.OrderLines.TotalQuantity-->');
if (iQuantity>0 || !isNaN(iQuantity)) {
document.getElementById('GlobalBasket').style.display = 'block'; // Or Inline
} else {
document.getElementById('GlobalBasketEmpty').style.display = 'block'; // Or Inline
}
</script>
I have added a "GlobalBasketEmpty" DIV to this example - it will be show in case of the basket is empty.
Tuesday, August 5, 2008
Anything in the basket?
By Sten Hougaard on Tuesday, August 05, 2008
Etiketter: Dynamic Web CMS, Dynamicweb Ecommerce
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment