Page 1 of 1

Hiding some products in kit products

Posted: Wed May 06, 2009 2:42 pm
by Carolharry
Hi Everyone,

We are doing some customization to not to show some products to particular user groups when they visit our store catalog.
Problem is we are building kit componets with Product A,B,C,D,E,F. In this Kit product there are some products which should be shown to particular user groups.

say we have to hide Product A and Product B from user group G1 when they view this kit product.

How do I do this. I went through BuyProductDialog.ascx and I don't see any code where kit products are binding to the phKitProducts control.

Can any one help where to find the exact place so that we can skip adding Product A and Product B when the user is from Group G1.

Thanks a lot in advance.
Carol

Re: Hiding some products in kit products

Posted: Thu May 07, 2009 3:54 am
by mazhar
Find out the calls to ProductHelper in BuyProductDialog control. You can found ProductHelper class under App_Code folder and check its BuildKitOptions function.

Re: Hiding some products in kit products

Posted: Thu May 07, 2009 8:36 am
by mazhar
Yes you are right that code is not accessible but you can process the control returned by code. For example if you are using radio button list then you can update the BuildKitOptions method radio button list part as below

Code: Select all

Type oType = o.GetType();
                    if (oType.Equals(typeof(RadioButtonList)))
                    {
                        ((RadioButtonList)o).AutoPostBack = true;
                        RadioButtonList rblist = ((RadioButtonList)o);
                        for (int i = 0; i < rblist.Items.Count; i++)
                        {
                            ListItem listItem = rblist.Items[i];
                            if (listItem != null)
                            {
                                KitProduct kitProduct = KitProductDataSource.Load(AlwaysConvert.ToInt(listItem.Value));
                                if (kitProduct.Name == "Hide This Product")
                                {
                                    rblist.Items.Remove(listItem);
                                    i = 0;
                                    continue;
                                }
                            }
                        }
                    }
I just imposed a very simple check to determine whether to show or hide this item

Code: Select all

if (kitProduct.Name == "Hide This Product")
you can replace with your custom logic.