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: Variants ... Restrict "Add To Cart"

  1. #1
    GoodFella is offline Member
    Join Date
    Mar 2009
    Posts
    99

    Default Variants ... Restrict "Add To Cart"

    I have a product with 6 Variants. Is it possible to set 1 of the 6 variants to not allow a user to add the product to cart?

    Thanks

  2. #2
    AspDotNetStorefront Staff - Scott's Avatar
    AspDotNetStorefront Staff - Scott is offline Administrator
    Join Date
    Mar 2007
    Location
    Ashland, OR
    Posts
    2,390

    Default

    The only variant-level way to keep a customer from adding to the cart would be with the Inventory.LimitCartToQuantityOnHand setting. If you set that up and then set the inventory for that variant to less than the quantity you selected, customers would get a little popup message (which is a string resource, so you can customize the text) if they tried to add to the cart. Note that this would apply across all products though, so might not work depending on your site.

    Everything else (hide add to cart button, filtering, etc) is at the product level.

  3. #3
    GoodFella is offline Member
    Join Date
    Mar 2009
    Posts
    99

    Default

    This could probably be accomplished with an XML mod though, right?

  4. #4
    ASPAlfred is offline Senior Member
    Join Date
    Nov 2007
    Posts
    2,244

    Default

    Nope, go to {root}/addtocart.aspx.cs file and see what you can do from there, you'll definitely need to hard-code (or probably add another field in the DB) the variant's unique identifier, so the cart will know which variant to filter. Btw, do you just want to display that variant and remove the 'add to cart' button beside it?

    If you can let us understand the reason why you want to achieve that, it might help us give you directions.

  5. #5
    GoodFella is offline Member
    Join Date
    Mar 2009
    Posts
    99

    Default

    Well,

    I have a series of products that require a user to enter a vehicle Make, Model and Year in a drop down control. I have a mapping table that maps Make, Model, year combinations to product/variants.

    When a user first visits a page (category page) and no Make, Model, or year are selected, I want to show all products but not allow the user to see any price or add to cart (or even show the price as: "From $100.00" (Where $100.00 is the smallest price among variants for any particular product.)

    I was thinking that I would have a particular variant for each of these products that would act as a default where no price is shown.

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

    Default

    You'd have to make a couple modifications...the Show Buy Button option applies at the product level so all variants will inherit this property. I'd recommend using something like the variant level extensiondata field...just use 0 (or blank) in the extensiondata field as one setting; make this the default value (since it's already blank for your items unless you've already customized the site to use it) and then use 1 as the flag to not show the buy button. Then, in your xmlpackage that you use for display of these items, make sure that the variant extensiondata is returned by the sql query (you may have to modify the query or a stored procedure depending on the package you are using...for example if you are using the product.variantsinrightbar.xml.config xmlpackage you'll need to modify the aspdnsf_ProductInfo sproc to retrieve and return the variant extension data):
    Code:
    SELECT   
           p.*,   
           pv.VariantID, pv.name VariantName, pv.Price, pv.Description VariantDescription, isnull(pv.SalePrice, 0) SalePrice, isnull(SkuSuffix, '') SkuSuffix, pv.Dimensions, pv.Weight, isnull(pv.Points, 0) Points, pv.Inventory, pv.ImageFilenameOverride VariantImageFilenameOverride,  pv.isdefault, pv.CustomerEntersPrice, isnull(pv.colors, '') Colors, isnull(pv.sizes, '') Sizes,  
           pv.ExtensionData VariantExtensionData, sp.name SalesPromptName,   
           case when pcl.productid is null then 0 else isnull(e.Price, 0) end ExtendedPrice
    and then around both the price lines, and the aspdnsf:AddtoCartForm lines do a check of that VariantExtensionData field AND whatever other conditions are necessary to see the price and add to cart button, i.e.
    Code:
    <xsl:choose>
    	<xsl:when test="number(VariantExtensionData) = 0 or VariantExtensionData = '' or 'your other test conditions here'">
    		<xsl:value-of select="aspdnsf:ShowQuantityDiscountTable(ProductID)" disable-output-escaping="yes"/>
    		<br/>
    		<xsl:value-of select="aspdnsf:AddtoCartForm(ProductID, VariantID, 0)" disable-output-escaping="yes"/>
    	</xsl:when>
    	<xsl:otherwise>
    		<!-- If you want to display some instructional information when the button doesn't display -->
    		<!-- this is where you should do it -->
    	</xsl:otherwise>
    </xsl:choose>
    <a href="http://www.aspdotnetstorefront.com">Shopping Cart Software</a>