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: Product page with color variant preselected

  1. #1
    RJD is offline Junior Member
    Join Date
    Nov 2009
    Posts
    2

    Default Product page with color variant preselected

    I have several custom webforms with links to product pages like:
    ...
    <a href="p-1-bag.aspx" title="My bag">
    ...
    <a href="p-10-shirt.aspx" title="My shirt">
    ..
    which when clicked land on the right product page (p-<prodid>-<prodname>.aspx)
    I would like to preselect the color variant depending on a query string like:
    <a href="p-10-shirt.aspx?color=red" title="My shirt"> (although this doesn't work)
    The variant dropdown shows the default "Select color". Is there a way to select the right color value by modifying the variantsindropdown package or where in the source could that be done?
    Thanks for your help with this

  2. #2
    chrismartz is offline Senior Member
    Join Date
    Apr 2010
    Posts
    339

    Default

    I did this by getting the value of the querystring:

    Code:
    <xsl:param name="Selection">
         <xsl:choose>
              <xsl:when test="/root/QueryString/color"><xsl:value-of select="/root/QueryString/color"/></xsl:when>
              <xsl:otherwise>0</xsl:otherwise>
         </xsl:choose>
    </xsl:param>
    Then within the drop-down, you will want to do an if to mark the selection:

    Code:
    <option value="{VariantID}">
    <xsl:if test="Color= $Selection"><xsl:attribute name="selected">selected</xsl:attribute></xsl:if>
         <xsl:value-of select="Color" />
    </option>
    This is just an example using color as the option. I actually used the variantID to do the selection. Its up to you though.

  3. #3
    RJD is offline Junior Member
    Join Date
    Nov 2009
    Posts
    2

    Default

    Thanks for your reply. I'm not sure when you say "then within the drop-down..." where exactly are you referring to in the product.VariantsInDropDown.xml.config file?
    I'm not very experienced with the packages and I'm missing on the code that refers to the dropdown for the color.
    Thanks for your help on this