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 3 of 3

Thread: Test more than one variant

  1. #1
    OmegaSpeed is offline Junior Member
    Join Date
    Jun 2009
    Posts
    20

    Default Test more than one variant

    I have a section that has different products -- some have more than one variant, others do not.

    I have a way to show a dropdown to select the variant, however, I only want this to showup if there is more than one variant. If there is only one variant, I just want it to show the price.

    Something like:

    PRODUCT 1
    Options: [___dropdown___]
    [Add to Cart]

    PRODUCT 2
    Price: $100.00
    [Add to Cart]


    Can anyone point me in the right direction on how to test for the total number of variants for a given product?
    Last edited by OmegaSpeed; 07-22-2009 at 12:12 AM.

  2. #2
    George the Great is offline Senior Member
    Join Date
    Nov 2006
    Location
    Cleveland, OH
    Posts
    1,792

    Default

    Have a look at the product.variantsinrightbar.xml.config xmlpackage. In the <xsl:template match="/"> section we do an <xsl:choose> that tests whether there are multiple variants or only one variant and then do something different based on what we find. Should be really close to what you're trying to do. If you're unsure about the xml structure that is being used to determine that, set debug="true" at the top of the xmlpackage and refresh the page using that xmlpackage; you'll get the full xml structure dumped on the page as well as a copy of that xml in the images directory of your site.
    <a href="http://www.aspdotnetstorefront.com">Shopping Cart Software</a>

  3. #3
    OmegaSpeed is offline Junior Member
    Join Date
    Jun 2009
    Posts
    20

    Default

    Perfect, thanks.

    For anyone who doesn't want to look it up, it is (you will have just to make sure you have the correct path for your XML -- e.g. "/root/ProductVariants/Variant"):

    Code:
    <xsl:choose>
    	<xsl:when test="count(/root/ProductVariants/Variant) &gt; 1">
    		....stuff to do when more than one variant...
    	</xsl:when>
    	<xsl:otherwise>
    		...stuff to do when only one variant...
    	</xsl:otherwise>
    </xsl:choose>