Important Notice from AspDotNetStorefront
It is with dismay that we report that we have been forced, through the action of hackers, to shut off write-access to this forum. We are keen to leave the wealth of material available to you for research. We have opened a new forum from which our community of users can seek help, support and advice from us and from each other. To post a new question to our community, please visit: http://forums.vortx.com
Results 1 to 6 of 6

Thread: Testing If Cart Has Items

  1. #1
    jeskey is offline Junior Member
    Join Date
    Oct 2006
    Posts
    25

    Default Testing If Cart Has Items

    I just upgraded from version 7 to version 8. I used to use this statement (below) in the minicart xml file for testing to see if i wanted to show the minicart based on it having contents. It no longer works and causes an exception so i assume it is no longer used.

    <xsl:if test="$CartHasItems!=''">
    ...
    </xsl:if>

    is there another way to do this?

    I do know there is a token: "(!NUM_CART_ITEMS!)" but that is not accessable.

  2. #2
    mgibbs is offline Senior Member
    Join Date
    Jan 2005
    Location
    Orange County, CA
    Posts
    194

    Default

    Jeskey,

    What we do is the following in a couple of our client's minicart code:
    HTML Code:
              <xsl:param name="ItemCount" select="count(/root/ShoppingCart/Item)" />
    
              <xsl:template match="/">
                  <xsl:choose>
                    <xsl:when test="$ItemCount &gt; 0 and $ItemCount &lt; 3 ">
                           ... code for the minicart if there are SOME items but less than 3 (ok, so that means just either 1 or two items
                    </xsl:when>
                    <xsl:when test="$ItemCount &gt; 2">
                           ... code for when there are 3 or more items in the cart
                    </xsl:when>
                    <xsl:otherwise>
                         <!-- No items in the cart so don't do anything -->
                    </xsl:otherwise>
                  </xsl:choose>
    I would imagine that you would just need to check if the $ItemCount is greater than 0 and keep the empty otherwise statement.

    Good luck!
    EMM for AspDotNetStorefront - Communicate effectively with your customers

  3. #3
    Jao is offline Senior Member
    Join Date
    Oct 2008
    Posts
    1,132

    Default

    Those lines of code and its structure you presented are very much okay and will do just fine.

  4. #4
    jeskey is offline Junior Member
    Join Date
    Oct 2006
    Posts
    25

    Default Minicart

    Thanks for you help....that worked perfectly. I am new to the whole xml / xsl and it is starting to make sense.

  5. #5
    mgibbs is offline Senior Member
    Join Date
    Jan 2005
    Location
    Orange County, CA
    Posts
    194

    Default

    Glad that worked out for you. I wouldn't say I'm an expert yet in the XMLPackages but glad to be able to give back given how much I've gotten from these forums.
    EMM for AspDotNetStorefront - Communicate effectively with your customers

  6. #6
    Univest is offline Member
    Join Date
    Feb 2010
    Posts
    30

    Question Doest work

    I have also implemented the code in my xml but the code you have provided doesnt work at all

    could you please look at the text file and see whats wrong with it.

    thank you
    Attached Files Attached Files