in

dashCommerce

An ASP.NET Open Source e-Commerce Application

Only Show Attribute items where stock available

Last post 07-10-2009 11:48 AM by chris.cyvas. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 06-19-2009 6:29 PM

    • macca
    • Top 500 Contributor
    • Joined on 06-17-2009
    • Posts 5

    Only Show Attribute items where stock available

    Hi dashCommerce community!

     I downloaded dashcommerce a week or so ago, built it in vs2008 and haven't looked back! I love it! I've just signed up for a year at dashcommerce.com and their hosting service is excellent, spot on.

     I've got something that I would love some help with that would absolutely transform the simplicity of setting up all the stock in the site and I'd be grateful of some help.

    I'm a "lapsed" programmer, last looked at ASP.NET before the days of ajax etc and although I understand some of the principals, I'm a bit lost in the source of dashcommerce.

     What I'm trying to do is this. When viewing an item, presented with its attributes, it would be wonderful if only the items that actually had skus in stock were shown in the attribute drop down lists. For example, if I have a pair of shoes to sell in sizes 10 and 12, it would be great if only items 10 and 12 appeared in the size attribute list, even if many more size options were defined against the attribute. Does that make any sense?

     Let me know if I need to ask the question in a different way.

     Looking forward to some feedback.

     

  • 06-19-2009 8:26 PM In reply to

    Re: Only Show Attribute items where stock available

    If you have a relatively simple case - like one attribute for a product, then pulling this off is easy - I think the code to do this is in the code base, but it's commented out BECAUSE . . . this gets tricky when you have multiple attributes. The Sku's for a product are the base sku + all the combinations of attributes for the product. So, you would have to create a way to look at the Sku's for a product and remove ONLY the combinations that result in 0 IN EVERY case. So, if you had a t shirt that had a color attribute and size attribute and a sleeve length attribute, you can see where you might have a red, small, long sleeve in stock, but you might be out of yellow, small, long sleeve - you still want the small and long sleeve options in the list. This is why we ajaxed the inventory lookup because this can get pretty tricky, pretty quick.
    --
    Big Smile ~ Chris

    Open Source = Community = Shared Responsibility = Submit A Patch!
  • 06-20-2009 2:40 PM In reply to

    • macca
    • Top 500 Contributor
    • Joined on 06-17-2009
    • Posts 5

    Re: Only Show Attribute items where stock available

    Thanks for the pointer Chris, I found the commented out code, it's just fine for what I need, very simple case, thanks for the pointer.

  • 06-22-2009 7:46 AM In reply to

    Re: Only Show Attribute items where stock available

    I implemented this for client.

    E-mail me at theonlylawislove@gmail.com if you are interested.

  • 07-03-2009 8:19 AM In reply to

    Re: Only Show Attribute items where stock available

     Is attributeSelector.ascx.cs the only place to comment out the code? I just edited and uploaded but it didn't change anything.

  • 07-08-2009 4:48 PM In reply to

    • macca
    • Top 500 Contributor
    • Joined on 06-17-2009
    • Posts 5

    Re: Only Show Attribute items where stock available

    So, this is what I did:
     
    Uncommented the following code on attributeSelector.ascx.cs
     
    //CMC: ?? Sku's are not made up of just BaseSku + 1 attribute, it's the combination of
    //BaseSku and ALL attributes.
    //start comment out here
    foreach (AttributeItem item in associatedAttribute.AttributeItemCollection)
    {
    if (!_product.AllowNegativeInventories)
    {
    Sku sku = ProductCache.GetSKU(_product.BaseSku + "-" + item.SkuSuffix);
    if (sku.SkuId > 0 && sku.Inventory > 0)
    dropDownList.Items.Add(
    new ListItem(item.FormattedAmount, item.SkuSuffix));
    }
    else
    dropDownList.Items.Add(
    new ListItem(item.FormattedAmount, item.SkuSuffix));
    }
    //end uncomment here
    Then I also commented out the following lines of code (just above the section that you've got to uncomment:
    //begin comment out
    //dropDownList.DataSource = associatedAttribute.AttributeItemCollection;
    //dropDownList.DataTextField = "FormattedAmount";
    //dropDownList.DataValueField = "SkuSuffix";
    //dropDownList.DataBind();
    //end comment out
     
    Doing this IS limiting though. I haven't tested how this code will perform if you have two attributes on a stock line (for example, size and colour) but I'm pretty sure it will break. I didn't even want to go there with my site so we get around that by having seperate stock lines where they come in different colours.
     

  • 07-10-2009 11:48 AM In reply to

    Re: Only Show Attribute items where stock available

    Yes, the scenario you mention is what I mention above. That's why I like the Ajax lookup for inventory level. Big Smile
    --
    Big Smile ~ Chris

    Open Source = Community = Shared Responsibility = Submit A Patch!
Page 1 of 1 (7 items)