Customize product page in ASPDNSF

930 views Asked by At

I am new to aspdotnetstorefront. I just installed a vanila website and connected with my database.

How to customize it or where can I learn how to customize it.

Ex:

enter image description here

Here I want that If there is 0 Inventory , change 'InStock' to 'OutOfStock' and hide AddToCart Button.

Can anyone give an example how to do it? I am a c# programmer.

2

There are 2 answers

1
Dean On BEST ANSWER

If this is a vanilla site its not that difficult to do.

Within your admin portal go to Configuration>Inventory Control

Change Out of stock threshold to a value of 0

and "Out of stock" message on product pages: to Out of Stock

You can hide products that have a quantity of 0 buy using the Hide products with less than this inventory level

5
Dean On

On the Inventory Control page within admin try setting the LimitCartToQuantityOnHand to True (tick the box) to see if that works.

If not then I have another solution.

  1. Backup your variantsindropdown xmlpackage and then modify to this

The page will work as follows. The Add to Cart and Add to Wishlist buttons will be disabled by default when the page loads, and the dropdown box selected value will be "--SELECT ONE--". Changing the dropdown to a value other than "--SELECT ONE--" will enable the buttons, and if you then change back to "--SELECT ONE--" the buttons will disable again.

If you have the appconfig DisplayOutOfStockOnProductPages set to "true", then any variants that have inventory less than HideProductsWithLessThanThisInventoryLevel appconfig parameter will be grayed-out/disabled.

If all variants in the list are grayed-out/disabled then they won't be able to add an item to the cart. If the appconfig DisplayOutOfStockOnProductPages is set to "false", then any variants that have inventory less than the value specified in the HideProductsWithLessThanThisInventoryLevel appconfig parameter will not be included in the dropdown list.

The only thing you'll need to be wary of is changing the text for the Add to Cart and Add to Wish List buttons. Because those buttons do not have IDs, finding the correct buttons involves looking at the elements of the AddToCartForm until you find the buttons with the text "Add to Cart" and "Add to Wish List". If you need to change your text (or if you already have) just replace the text in the XmlPackage with the text that you are now using for the buttons.

<?xml version="1.0" standalone="yes" ?>

<!-- ###################################################################################################### -->
<!-- Copyright AspDotNetStorefront.com, 1995-2009.  All Rights Reserved.                                    -->
<!-- http://www.aspdotnetstorefront.com                                                                     -->
<!-- For details on this license please visit  the product homepage at the URL above.                       -->
<!-- THE ABOVE NOTICE MUST REMAIN INTACT.                                                                   -->
<!--                                                                                                        -->
<!-- ###################################################################################################### -->


<query name="Products" rowElementName="Product">
    <sql>
        <![CDATA[
            exec dbo.aspdnsf_ProductInfo @ProductID, @CustomerLevelID, 1, 0, @affiliateID
        ]]>
    </sql>
    <queryparam paramname="@ProductID"       paramtype="request" requestparamname="ProductID"       sqlDataType="int" defvalue="0"  validationpattern="^\d{1,10}$" />
    <queryparam paramname="@CustomerLevelID" paramtype="runtime" requestparamname="CustomerLevelID" sqlDataType="int" defvalue="0"  validationpattern="" />
    <queryparam paramname="@affiliateID"     paramtype="system"  requestparamname="AffiliateID"     sqlDataType="int" defvalue="0"  validationpattern="" />
</query>

<query name="ProductVariants" rowElementName="Variant">
    <sql>
        <![CDATA[
            select pv.VariantID, pv.Name, pv.Price, pv.Description, pv.ProductID, pv.Deleted, pv.MinimumQuantity,
            pv.Published, pv.Points, pv.IsDefault, pv.DisplayOrder, case p.TrackInventoryBySizeAndColor when 1 then isnull(i.quan, 0) else pv.inventory end Inventory,
            case when pv.SalePrice is null then 0 else isnull(pv.SalePrice, 0) end SalePrice, case when pcl.productid is null then 0 else isnull(e.Price, 0) end ExtendedPrice
            from dbo.productvariant pv with (nolock)
                join dbo.product p with (nolock) on p.productid = pv.productid
                left join dbo.ExtendedPrice e with (nolock) on pv.VariantID=e.VariantID and e.CustomerLevelID=@CustomerLevelID
                left join dbo.ProductCustomerLevel pcl with (NOLOCK) on pcl.ProductID = p.ProductID and pcl.CustomerLevelID = @CustomerLevelID
                left join dbo.Inventory i with (nolock) on i.VariantID = pv.VariantID
            where pv.ProductID=@ProductID and pv.Deleted=0  and pv.Published = 1
            order by pv.IsDefault DESC, pv.DisplayOrder ASC
        ]]>
    </sql>
    <queryparam paramname="@CustomerLevelID" paramtype="system"     requestparamname="CustomerLevelID"                            sqlDataType="int" defvalue="0"  validationpattern="" />
    <queryparam paramname="@ProductID"       paramtype="request"    requestparamname="ProductID"                                  sqlDataType="int" defvalue="0"  validationpattern="" />
    <queryparam paramname="@InvFilter"       paramtype="appconfig"  requestparamname="HideProductsWithLessThanThisInventoryLevel" sqlDataType="int" defvalue="0"  validationpattern="" />
</query>

<PackageTransform>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:aspdnsf="urn:aspdnsf" exclude-result-prefixes="aspdnsf">
        <xsl:output method="html" omit-xml-declaration="yes" />

        <xsl:param name="defaultVariant">
            <xsl:choose>
                <xsl:when test="count(/root/ProductVariants/Variant[IsDefault=1]) = 0"><xsl:value-of select="/root/ProductVariants/Variant[1]/VariantID" /></xsl:when>
                <xsl:otherwise><xsl:value-of select="/root/ProductVariants/Variant[IsDefault=1]/VariantID" /></xsl:otherwise>
            </xsl:choose>
        </xsl:param>
        <xsl:param name="LocaleSetting" select="/root/Runtime/LocaleSetting" />
        <xsl:param name="WebConfigLocaleSetting" select="/root/Runtime/WebConfigLocaleSetting" />
        <xsl:param name="XmlPackageName" select="/root/System/XmlPackageName" />


        <xsl:param name="SecID">
            <xsl:choose>
              <xsl:when test="count(/root/QueryString/sectionid) &gt; 0">
                <xsl:value-of select="/root/QueryString/sectionid" />
              </xsl:when>
              <xsl:otherwise>0</xsl:otherwise>
            </xsl:choose>
        </xsl:param>

        <xsl:param name="CatID">
            <xsl:choose>
              <xsl:when test="count(/root/QueryString/categoryid) &gt; 0">
                <xsl:value-of select="/root/QueryString/categoryid" />
              </xsl:when>
              <xsl:otherwise>0</xsl:otherwise>
            </xsl:choose>
        </xsl:param>

        <xsl:template match="/">
            <xsl:apply-templates select="/root/Products/Product" />
            <SCRIPT LANGUAGE="JavaScript">
              var theForm = document.forms["AddToCartForm_<xsl:value-of select="/root/QueryString/productid" />_<xsl:value-of select="$defaultVariant" />"];
              for(e = 0; e &lt; theForm.elements.length; e+=1)
              {
                if(theForm.elements[e].value == 'Add to Cart')
                {
                  theForm.elements[e].disabled = 'true';
                }
                if(theForm.elements[e].value == 'Add to Wish List')
                {
                  theForm.elements[e].disabled = 'true';
                }
              }

              var VarMinQty = new Array();
              var VarInventory = new Array();
              <xsl:for-each select="/root/ProductVariants/Variant">
                  <xsl:choose>
                    <xsl:when test="MinimumQuantity &gt; 0">
                      VarMinQty[<xsl:value-of select="VariantID" />] = <xsl:value-of select="MinimumQuantity" />;
                    </xsl:when>
                    <xsl:otherwise>
                      VarMinQty[<xsl:value-of select="VariantID" />] = 1;
                    </xsl:otherwise>
                  </xsl:choose>
                  VarInventory[<xsl:value-of select="VariantID" />] = <xsl:value-of select="Inventory" />;
                </xsl:for-each>

                function SetCartVariant(selValue){
                    //alert("AddToCartForm_"+prodid+"_"+varid);
                    var theForm = document.forms["AddToCartForm_<xsl:value-of select="/root/QueryString/productid" />_<xsl:value-of select="$defaultVariant" />"];



              if(selValue=='')
              {
                //alert('Please select a variant to add to the cart');
                for(e = 0; e &lt; theForm.elements.length; e+=1)
                {
                  if(theForm.elements[e].value == 'Add to Cart')
                  {
                    theForm.elements[e].disabled = 'true';
                  }
                  if(theForm.elements[e].value == 'Add to Wish List')
                  {
                    theForm.elements[e].disabled = 'true';
                  }
                }
              }
              else 
              {
                for(e = 0; e &lt; theForm.elements.length; e+=1)
                {
                  if(theForm.elements[e].value == 'Add to Cart')
                  {
                    theForm.elements[e].disabled = '';
                  }
                  if(theForm.elements[e].value == 'Add to Wish List')
                  {
                    theForm.elements[e].disabled = '';
                  }
                }

              theForm.VariantID.value=selValue;
              VariantMinimumQty_<xsl:value-of select="/root/QueryString/productid" />_<xsl:value-of select="$defaultVariant" /> = VarMinQty[selValue];
                        SelectedVariantInventory_<xsl:value-of select="/root/QueryString/productid" />_<xsl:value-of select="$defaultVariant" /> = VarInventory[selValue];
                    }
                }
                SelectedVariantInventory_<xsl:value-of select="/root/QueryString/productid" />_<xsl:value-of select="$defaultVariant" /> = VarInventory[<xsl:value-of select="$defaultVariant" />];
            </SCRIPT>
            <xsl:comment>Copyright 1995-2009 AspDotNetStorefront.com</xsl:comment>
        </xsl:template>


    <xsl:template match="Product">
        <xsl:param name="pName" select="aspdnsf:GetMLValue(Name)"></xsl:param>
        <xsl:param name="pDescription" select="aspdnsf:GetMLValue(Description)"></xsl:param>
        <xsl:param name="pSEAltText" select="aspdnsf:GetMLValue(SEAltText)"></xsl:param>
        <xsl:param name="AltText">
            <xsl:choose>
                <xsl:when test="$pSEAltText=''"><xsl:value-of select="$pName" /></xsl:when>
                <xsl:otherwise><xsl:value-of select="$pSEAltText" /></xsl:otherwise>
            </xsl:choose>
        </xsl:param>

        <xsl:choose>
          <xsl:when test="IsAKit=1">
            <table border="0" width="100%" cellpadding="4" cellspacing="0">
              <tr>
                <td align="left" valign="top">
                  <xsl:value-of select="aspdnsf:LookupProductImage(ProductID, ImageFilenameOverride, SKU, 'medium', 1, $AltText)" disable-output-escaping="yes"/>
                </td>
                <td align="left" valign="top" width="100%">
                  <div>
                    <table width="100%" cellpadding="0" cellspacing="0">
                      <tr>
                        <td width="100%" align="left" valign="middle">
                          <span class="ProductNameText">
                            <xsl:value-of select="$pName" disable-output-escaping="yes" />
                          </span>
                        </td>
                        <td align="right" valign="Middle">
                          <nobr>
                            <xsl:value-of select="aspdnsf:ProductNavLinks(ProductID, $CatID, $SecID)" disable-output-escaping="yes" />
                          </nobr>
                        </td>
                      </tr>
                    </table>
                  </div>
                  <div>
                    <br />
                  </div>
                  <div>
                    <b>
                      <font color="red">
                        Display of Kit Products is not supported by this XmlPackage.<br /><br />XmlPackage=<xsl:value-of select="$XmlPackageName" />
                      </font>
                    </b>
                  </div>
                </td>
              </tr>
            </table>
          </xsl:when>
          <xsl:when test="IsAPack=1">
            <table border="0" width="100%" cellpadding="4" cellspacing="0">
              <tr>
                <td align="left" valign="top">
                  <xsl:value-of select="aspdnsf:LookupProductImage(ProductID, ImageFilenameOverride, SKU, 'medium', 1, $AltText)" disable-output-escaping="yes"/>
                </td>
                <td align="left" valign="top" width="100%">
                  <div>
                    <table width="100%" cellpadding="0" cellspacing="0">
                      <tr>
                        <td width="100%" align="left" valign="middle">
                          <span class="ProductNameText">
                            <xsl:value-of select="$pName" disable-output-escaping="yes" />
                          </span>
                        </td>
                        <td align="right" valign="Middle">
                          <nobr>
                            <xsl:value-of select="aspdnsf:ProductNavLinks(ProductID, $CatID, $SecID)" disable-output-escaping="yes" />
                          </nobr>
                        </td>
                      </tr>
                    </table>
                  </div>
                  <div>
                    <br />
                  </div>
                  <div>
                    <b>
                      <font color="red">
                        Display of Pack Products is not supported by this XmlPackage.<br /><br />XmlPackage=<xsl:value-of select="$XmlPackageName" />
                      </font>
                    </b>
                  </div>
                </td>
              </tr>
            </table>
          </xsl:when>
          <xsl:otherwise>
            <table border="0" width="100%" cellpadding="4" cellspacing="0">
              <tr>
                <td align="left" valign="top">
                  <xsl:value-of select="aspdnsf:LookupProductImage(ProductID, ImageFilenameOverride, SKU, 'medium', 1, $AltText)" disable-output-escaping="yes"/>
                </td>
                <td align="left" valign="top" width="100%">
                  <div>
                    <table width="100%" cellpadding="0" cellspacing="0">
                      <tr>
                        <td width="100%" align="left" valign="middle">
                          <span class="ProductNameText">
                            <xsl:value-of select="$pName" disable-output-escaping="yes" />
                          </span>
                          <br/>
                        </td>
                        <td align="right" valign="Middle">
                          <nobr>
                            <xsl:value-of select="aspdnsf:ProductNavLinks(ProductID, /root/Runtime/EntityID, /root/Runtime/EntityName, /root/EntityHelpers/*[name()=/root/Runtime/EntityName]/descendant::Entity[EntityID=/root/Runtime/EntityID]/SEName, 0, 1, 1)" disable-output-escaping="yes" />
                            <xsl:value-of select="aspdnsf:EmailProductToFriend(ProductID, $CatID)" disable-output-escaping="yes"/>
                          </nobr>
                        </td>
                      </tr>
                    </table>
                  </div>
                  <div>
                  </div>
                  <div>
                    <xsl:value-of select="$pDescription" disable-output-escaping="yes"/>                         
                    <br/>
                    <br/>
                  </div>
                  <div>
                  </div>
                  <div>
                    Options: <select name="variants" onchange="SetCartVariant(this.value)">
                      <option value="" selected="selected">--SELECT ONE--</option>
                      <xsl:apply-templates select="/root/ProductVariants/Variant" />
                    </select>
                      <xsl:if test="aspdnsf:AppConfigBool('DisplayOutOfStockProducts') = 'true'">
                          <xsl:value-of select="aspdnsf:DisplayProductStockHint(ProductID, VariantID, 'Product')" disable-output-escaping="yes" />
                      </xsl:if>
                    <div>
                      <br/>
                    </div>
                    <xsl:value-of select="aspdnsf:AddtoCartForm(ProductID, $defaultVariant, 1)" disable-output-escaping="yes"/>
                  </div>
                </td>
              </tr>                 
            </table>
              <xsl:value-of select="aspdnsf:RelatedProducts(ProductID)" disable-output-escaping="yes"/>
              <xsl:value-of select="aspdnsf:RecentlyViewed(ProductID)" disable-output-escaping="yes"/>
              <xsl:value-of select="aspdnsf:ShowUpsellProducts(ProductID)" disable-output-escaping="yes"/>
              <xsl:value-of select="aspdnsf:AlsoBought(ProductID, VariantID)" disable-output-escaping="yes"/>
              <xsl:value-of select="aspdnsf:ProductSpecs(ProductID, 1)" disable-output-escaping="yes"/>
              <xsl:value-of select="aspdnsf:ProductRatings(ProductID, 0, 0, 0, 1)" disable-output-escaping="yes"/>
            <xsl:value-of select="aspdnsf:Topic('imagepricetable')" disable-output-escaping="yes" />
          </xsl:otherwise>
        </xsl:choose>
    </xsl:template>


  <xsl:template match="Variant">
    <xsl:param name="vName" select="aspdnsf:GetMLValue(Name)"></xsl:param>
    <xsl:param name="pSalesPromptName" select="aspdnsf:GetMLValue(/root/Products/Product/SalesPromptName)"></xsl:param>
    <xsl:param name="pTaxClassID" select="/root/Products/Product/TaxClassID" />
    <xsl:choose>
      <xsl:when test="aspdnsf:AppConfig('DisplayOutOfStockOnProductPages') = 'true'">
        <option value="{VariantID}">
          <xsl:if test="Inventory &lt; aspdnsf:AppConfig('HideProductsWithLessThanThisInventoryLevel')">
            <xsl:attribute name="disabled">disabled</xsl:attribute>
          </xsl:if>
          <xsl:value-of select="$vName" />*-*<xsl:value-of select="aspdnsf:GetVariantPrice(VariantID, number(HidePriceUntilCart), Price, SalePrice, ExtendedPrice, Points, $pSalesPromptName, $pTaxClassID)" disable-output-escaping="yes" />
        </option>
      </xsl:when>
      <xsl:otherwise>
        <xsl:if test="Inventory &gt; (number(aspdnsf:AppConfig('HideProductsWithLessThanThisInventoryLevel')) - 1)">
          <option value="{VariantID}">
            <xsl:value-of select="$vName" />*-*<xsl:value-of select="aspdnsf:GetVariantPrice(VariantID, number(HidePriceUntilCart), Price, SalePrice, ExtendedPrice, Points, $pSalesPromptName, $pTaxClassID)" disable-output-escaping="yes" />
        </option>
        </xsl:if>
      </xsl:otherwise>
    </xsl:choose>

  </xsl:template>
</xsl:stylesheet>