Hiding some products in kit products

This forum is where we'll mirror posts that are of value to the community so they may be more easily found.
Post Reply
Carolharry
Commander (CMDR)
Commander (CMDR)
Posts: 121
Joined: Wed Dec 17, 2008 9:13 am

Hiding some products in kit products

Post by Carolharry » Wed May 06, 2009 2:42 pm

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

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

Re: Hiding some products in kit products

Post by mazhar » Thu May 07, 2009 3:54 am

Find out the calls to ProductHelper in BuyProductDialog control. You can found ProductHelper class under App_Code folder and check its BuildKitOptions function.

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

Re: Hiding some products in kit products

Post by mazhar » Thu May 07, 2009 8:36 am

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.

Post Reply