kit and show variants in stock

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
lars-erik
Ensign (ENS)
Ensign (ENS)
Posts: 5
Joined: Tue Apr 07, 2009 2:58 am

kit and show variants in stock

Post by lars-erik » Tue Apr 07, 2009 3:11 am

Regarding kits.
I want to display items in stock at each variant.
Now, in the radiobuttonlist / dropdown list, it displays only "2 GB Dual Channel DDR2 SDRAM at 667MHz- 2DIMMs - (kr 0.00)" .
I want to display: "2 GB Dual Channel DDR2 SDRAM at 667MHz- 2DIMMs - (kr 0.00) - 12 items in stock"
Is this possible? Where ?
Do I need to buy the source code?

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: kit and show variants in stock

Post by mazhar » Tue Apr 07, 2009 6:07 am

No need to buy source for this change. Try following fix

Go to following method

Code: Select all

public static List<int> BuildKitOptions(Product product, PlaceHolder phOptions)
in App_Code/ProductHelper.cs class and locate following code lines

Code: Select all

if (o != null)
                {
                    Type oType = o.GetType();
                    if (oType.Equals(typeof(RadioButtonList)))
                    {
                        ((RadioButtonList)o).AutoPostBack = true;
                    }
                    else if (oType.Equals(typeof(DropDownList)))
                    {
                        ((DropDownList)o).AutoPostBack = true;
                    }
                    else if (oType.Equals(typeof(CheckBoxList)))
                    {
                        ((CheckBoxList)o).AutoPostBack = true;
                    }
                    phOptions.Controls.Add(o);
                    // SEE WHETHER A VALID VALUE FOR THIS FIELD IS PRESENT IN FORM POST
                    List<int> theseOptions = component.GetControlValue(o);
                    selectedChoices.AddRange(theseOptions);
                }
and replace them with below code block

Code: Select all

if (o != null)
                {
                    Type oType = o.GetType();
                    if (oType.Equals(typeof(RadioButtonList)))
                    {
                        ((RadioButtonList)o).AutoPostBack = true;
                        RadioButtonList rbl = ((RadioButtonList)o);

                        foreach (KitProduct kitProduct in component.KitProducts)
                        {
                            ListItem listItem = rbl.Items.FindByValue(kitProduct.KitProductId.ToString());
                            if (listItem != null)
                                listItem.Text += string.Format("- {0} item{1} in stock", kitProduct.Product.InStock,(kitProduct.Product.InStock > 1)?"s":string.Empty);
                        }

                    }
                    else if (oType.Equals(typeof(DropDownList)))
                    {
                        ((DropDownList)o).AutoPostBack = true;
                        DropDownList ddl = ((DropDownList)o);

                        foreach (KitProduct kitProduct in component.KitProducts)
                        {
                            ListItem listItem = ddl.Items.FindByValue(kitProduct.KitProductId.ToString());
                            if (listItem != null)
                                listItem.Text += string.Format("- {0} item{1} in stock", kitProduct.Product.InStock, (kitProduct.Product.InStock > 1) ? "s" : string.Empty);
                        }
                    }
                    else if (oType.Equals(typeof(CheckBoxList)))
                    {
                        ((CheckBoxList)o).AutoPostBack = true;

                        CheckBoxList chkl = ((CheckBoxList)o);
                        foreach (KitProduct kitProduct in component.KitProducts)
                        {
                            ListItem listItem = chkl.Items.FindByValue(kitProduct.KitProductId.ToString());
                            if (listItem != null)
                                listItem.Text += string.Format("- {0} item{1} in stock", kitProduct.Product.InStock, (kitProduct.Product.InStock > 1) ? "s" : string.Empty);
                        }
                    }
                    phOptions.Controls.Add(o);
                    // SEE WHETHER A VALID VALUE FOR THIS FIELD IS PRESENT IN FORM POST
                    List<int> theseOptions = component.GetControlValue(o);
                    selectedChoices.AddRange(theseOptions);
                }

lars-erik
Ensign (ENS)
Ensign (ENS)
Posts: 5
Joined: Tue Apr 07, 2009 2:58 am

Re: kit and show variants in stock

Post by lars-erik » Tue Apr 07, 2009 6:38 am

Yes, that works if inventory tracking is set to Track Products, but it displays "0 items in stock" if the inventory tracking is set to "Track Variants". (E.g. against the t-shirts)
And I have double checked that stock is set >0 on the variants.
Please, help me. I am almost there now...


lars-erik
Ensign (ENS)
Ensign (ENS)
Posts: 5
Joined: Tue Apr 07, 2009 2:58 am

Re: kit and show variants in stock

Post by lars-erik » Tue Apr 07, 2009 7:57 am

Thank's for the links regarding multilanguage.
But can you still help me with showing stocks for variants. (I just changed my previous post when I discovered that it shows "0 items in stock" when an option in a kit is mapped to a variant in another product. (e.g. mapping to Male, Large in the shirt product).

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: kit and show variants in stock

Post by mazhar » Wed Apr 08, 2009 8:46 am

You can update the if statement as below to take care of product variants as well

Code: Select all

if (listItem != null)
                            {
                                if(kitProduct.ProductVariant != null)
                                    listItem.Text += string.Format("- {0} item{1} in stock", kitProduct.ProductVariant.InStock, (kitProduct.ProductVariant.InStock > 1) ? "s" : string.Empty);
                                else
                                    listItem.Text += string.Format("- {0} item{1} in stock", kitProduct.Product.InStock, (kitProduct.Product.InStock > 1) ? "s" : string.Empty);
                            }

lars-erik
Ensign (ENS)
Ensign (ENS)
Posts: 5
Joined: Tue Apr 07, 2009 2:58 am

Re: kit and show variants in stock

Post by lars-erik » Fri Apr 10, 2009 2:07 am

Great ! Thank you.

I have a proposal for improvement for the next version:
E.g. take the t-shirt in demo (presented as an ordinary product, not kit), this comes in sizes (small,large...) and gender (male,female).
Now then, instead of selecting from two drop-down-list (gender and size), let the user select from a single drop-down-list/radio-buttons. Like this:
* Male, Small, 2 items in stock
* Male, Large, 4 items in stock
...
* Female, Small, Out of stock. Approx. 3 weeks of delivery time.
* Female, Medium, 1 item in stock.
..

This will show the currrent stock to the user immediately - he doesn't need to select from two different combos in order to make the "out-of-stock-message" appear.
If backorders are not allowed, the variant combination should not appear at all.
If backorders are allowed, an approximately delivery time should be showed to the user (e.g. 3 weeks of delivery time). This should be given at each product.
The only way to solve this today, is to use kits and putting the delivery time into one of the existing field (e.g. at end of the SKU separated by a semi-colon).
You should consider this, I have seen a lot of norwegian shopping systems that has this functionality.

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: kit and show variants in stock

Post by mazhar » Fri Apr 10, 2009 4:49 am

lars-erik wrote:Great ! Thank you.

I have a proposal for improvement for the next version:
E.g. take the t-shirt in demo (presented as an ordinary product, not kit), this comes in sizes (small,large...) and gender (male,female).
Now then, instead of selecting from two drop-down-list (gender and size), let the user select from a single drop-down-list/radio-buttons. Like this:
* Male, Small, 2 items in stock
* Male, Large, 4 items in stock
...
* Female, Small, Out of stock. Approx. 3 weeks of delivery time.
* Female, Medium, 1 item in stock.
..

This will show the currrent stock to the user immediately - he doesn't need to select from two different combos in order to make the "out-of-stock-message" appear.
If backorders are not allowed, the variant combination should not appear at all.
If backorders are allowed, an approximately delivery time should be showed to the user (e.g. 3 weeks of delivery time). This should be given at each product.
The only way to solve this today, is to use kits and putting the delivery time into one of the existing field (e.g. at end of the SKU separated by a semi-colon).
You should consider this, I have seen a lot of norwegian shopping systems that has this functionality.
If you think this is something helpful you can create a poll in feature request forum.

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: kit and show variants in stock

Post by jmestep » Fri Apr 10, 2009 5:32 am

You could do the dual options now by making the option a combination of the size and color instead of separate fields.
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

lars-erik
Ensign (ENS)
Ensign (ENS)
Posts: 5
Joined: Tue Apr 07, 2009 2:58 am

Re: kit and show variants in stock

Post by lars-erik » Mon May 25, 2009 4:32 am

Can the same thing be achieved with non-kit products with a 1-dimension variant ?
I sell shoes, and want to display the available sizes in stock in the text in the drop-down-list. I DON'T want the customer to be notified with a "out-of-stock" message after the shoe size is selected.
E.g.
Shoe,
the text in the drop-down-list:
Choose size:
<42, 12 items in stock>
<43, no items in stock>

Is this possible?

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: kit and show variants in stock

Post by mazhar » Mon May 25, 2009 5:45 am

Edit your ProductHelper.cs class BuildProductOptions method and locate following code block in code section where dropdown list being added dynamically

Code: Select all

foreach (OptionChoice optionOption in availableOptions)
                    {
                        aspOptions.Items.Add(new ListItem(optionOption.Name, optionOption.OptionChoiceId.ToString()));
                    }
and then change it as below

Code: Select all

foreach (OptionChoice optionOption in availableOptions)
                    {
                        List<int> chList = new List<int>();
                        chList.Add(optionOption.OptionChoiceId);
                        ProductVariant productVariant = ProductVariantDataSource.LoadForOptionList(product.ProductId, chList.ToArray());

                        if (productVariant != null)
                        {
                            string msg = string.Format("- {0} item{1} in stock", productVariant.InStock, (productVariant.InStock > 1) ? "s" : string.Empty);
                            aspOptions.Items.Add(new ListItem(optionOption.Name + msg , optionOption.OptionChoiceId.ToString()));
                        }
                        else
                            aspOptions.Items.Add(new ListItem(optionOption.Name, optionOption.OptionChoiceId.ToString()));
                    }

Post Reply