A blog for Dynamicweb CMS and Dynamicweb eCommers users and developers

Show/hide global basket using if-defined

If you have a Dynamicweb eCommerce based website you may have placed a global basket in the master file (DW7 design or old style master template). Here is a quick and dirty example of controling html should be included if the basket is not empty.

<!--@If Defined(Ecom:Order.OrderLines.Count)-->
<li class="bag"><a href="shopping-basket.aspx"><img src="basketIcon.gif" alt="Basket contains <!--@Ecom:Order.OrderLines.Count--> items" />Basket</a></li>
<!--@EndIf(Ecom:Order.OrderLines.Count)-->

This may be a part of a “servicemenu” for instance at the top right of the page, therefore I have used an LI as container. There is a link to a page which shows the complete basket. The reason that I have add an alternative text on the icon which informs about the number of items in the basket is that I have found out the sometimes the if-defined will not work if the tag is not used on the page…

Do you want to share a quick-and-dirty code snippet for Dynamicweb or Dynamicweb eCommerce, please feel free to contact me.

Share

About Sten Hougaard

I am a frontend developer working professionally with implementing websites using Dynamicweb CMS and other CMS systems. I work for 727 online (www.727.dk) in Denmark. My stengths are jQuery, XSLT, HTML, CSS and other frontend related technologies.
This entry was posted in Examples, Frontend, Quickguides and tagged . Bookmark the permalink.
US

3 Responses to Show/hide global basket using if-defined

  1. Bille says:

    Hi Steen

    I saw your article, and its very useful. But how do you make a global basket?
    Do you have some link to any documentation on that subject?

    Thanks
    //Bille

    • Hi Bille,
      Actually Dynamicweb will expose tags related to basket if the basket if some orderlines exists (the visitor has added goods to the basket).
      All this is ofcause only possibel if you have a Dynamicweb eCommerce installed and set up on the website.
      The code lines above can be copy’n'pasted into a MASTER template. The master template can be inside a layout template (/files/templates/design/[yourTemplateFolder]/master.html) or the old style master template (/files/templates/master/myMaster.html) .
      You may write to me netsi1964@gmail.com if you need more help.

      /Sten

  2. Bille says:

    Hi Steen,

    Great, I think have figured it out. The addcart command adds products to “all baskets” in the setup. So I made a new basket and then I have 2 baskets:

    1. One with the “global template”
    2. One which is the step basket.

    thats very versatile.

    //thanks :-)

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>