【问题标题】:Customize product page in ASPDNSF在 ASPDNSF 中自定义产品页面
【发布时间】:2014-05-23 18:02:03
【问题描述】:

我是 aspdotnetstorefront 的新手。我刚刚安装了一个 vanila 网站并连接到我的数据库。

如何自定义或在哪里可以学习如何自定义。

例如:

这里我想要如果有 0 Inventory,将 'InStock' 更改为 'OutOfStock' 并隐藏 AddToCart 按钮。

谁能举例说明怎么做? 我是一名 C# 程序员。

【问题讨论】:

    标签: c# aspdotnetstorefront


    【解决方案1】:

    如果这是一个普通网站,那么做起来并不难。

    在您的管理门户中转到配置>库存控制

    缺货阈值更改为 0

    和产品页面上的“缺货”消息:缺货

    您可以使用隐藏低于此库存水平的产品来隐藏购买数量为 0 的产品

    【讨论】:

    • 对于具有多个 ProductVariants 的单个产品,如果所有 ProductVariant 的库存为 0,则显示 OutOfStock。当我从下拉菜单中单击特定 ProductVariant 时,如何显示缺货?
    【解决方案2】:

    在管理员内的库存控制页面上,尝试将 LimitCartToQuantityOnHand 设置为 True(勾选该框)以查看是否有效。

    如果没有,那么我有另一个解决方案。

    1. 备份你的variantsindropdown xmlpackage然后修改到这个

    页面将按如下方式工作。页面加载时默认禁用“添加到购物车”和“添加到愿望清单”按钮,下拉框选择值为“--SELECT ONE--”。将下拉列表更改为“--SELECT ONE--”以外的值将启用按钮,如果您随后更改回“--SELECT ONE--”,则按钮将再次禁用。

    如果您将 appconfig DisplayOutOfStockOnProductPages 设置为“true”,则库存少于 HideProductsWithLessThanThisInventoryLevel appconfig 参数的任何变体都将灰显/禁用。

    如果列表中的所有变体都显示为灰色/禁用,则它们将无法将商品添加到购物车。如果 appconfig DisplayOutOfStockOnProductPages 设置为“false”,则任何库存小于 HideProductsWithLessThanThisInventoryLevel appconfig 参数中指定值的变体都不会包含在下拉列表中。

    您唯一需要注意的是更改“添加到购物车”和“添加到愿望清单”按钮的文本。因为这些按钮没有 ID,所以要找到正确的按钮需要查看 AddToCartForm 的元素,直到找到带有“添加到购物车”和“添加到愿望清单”文本的按钮。如果您需要更改您的文本(或者如果您已经有),只需将 XmlPackage 中的文本替换为您现在用于按钮的文本。

    <?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>
    

    【讨论】:

    • 如果保管箱中的第一个项目(默认产品变体)有库存,则显示 InStock,如果第一个项目(默认产品变体)库存为 0,则无论所有其他产品变体如何,它都显示 OutOfStock。
    • 出现此错误:无法处理请求我们无法处理您的请求。请再试一次。如果您继续收到此消息,请单击此处联系我们的客户服务部门。我们对不便表示抱歉。作为系统管理员,您可以在管理站点中查看此错误的内容,方法是转到配置 --> 维护 --> 系统日志
    • 我会看一个这样的插件,看看这是否是你所追求的。 ecommercecartmods.com/…
    • 你可以去你的系统日志并复制错误代码吗?
    • 是的..我做到了,这是一个标签不匹配..我修复了。它显示带有“--SELECT ONE--”的产品页面。但不会禁用 AddtoCartButton 并且不会根据下拉列表中的选择更改 Stock 消息。谢谢
    猜你喜欢
    • 1970-01-01
    • 2021-06-24
    • 2020-11-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-22
    相关资源
    最近更新 更多