Page 1 of 1

Display Kit Options on Category Pages

Posted: Tue Jan 13, 2009 11:12 am
by dappy2
Is it possible to display a products kit options and/or product options on the category page?

We have a few products that will have kit options. When a user clicks "buy" it takes them to the product detail page. This is confusing to the user especially since products that don't have a kit go right to the basket.

I want to display those options so that products can be purchased right from the category pages if desired. I looked around in the code and couldn't find anything that seemed to reference or pull these options. I tried adding the code below to my category display:

Code: Select all

			<asp:PlaceHolder runat="server" id="phOptions" EnableViewState="false"></asp:PlaceHolder>
			<asp:PlaceHolder ID="phAddToBasketWarningOpt" runat="server" EnableViewState="false" Visible="false">
                    <asp:Label ID="AddToBasketWarningOpt" runat="server" EnableViewState="false"  SkinID="ErrorCondition" Text="Please make your selections above."></asp:Label>
			</asp:PlaceHolder>
			<asp:PlaceHolder runat="server" id="phKitOptions" EnableViewState="false"></asp:PlaceHolder>
			<asp:PlaceHolder ID="phAddToBasketWarningKit" runat="server" EnableViewState="false" Visible="false">
                    <asp:Label ID="AddToBasketWarningKit" runat="server" EnableViewState="false"  SkinID="ErrorCondition" Text="Please make your selections above."></asp:Label>
			</asp:PlaceHolder>
Obviously this didn't work, but didn't throw an error either as I expected. There is quite a bit of code in BuyProductDialog.ascx.cs that seems to reference and check for options/kits. Can I pull that code out and add it to my catalog codebehind along with the above to display the options?

Has anyone done this already? Searching didn't turn up much on the forums.

Thanks,
Dappy

Re: Display Kit Options on Category Pages

Posted: Tue Jan 13, 2009 11:23 am
by mazhar
The code building kits options is inside the App_Code/ProductHelper.BuildKitOptions and some other similar methods in ProductHelper class.

Re: Display Kit Options on Category Pages

Posted: Tue Jun 16, 2009 8:01 am
by dappy2
Sorry to resurrect a post from the depths. I've finally gotten to working on this and made some progress.

I've rebuilt a category product display page with a different layout. I've got kit options showing. We don't use many, we have 1 product with the option to add some accessories (displays a checkbox list) and a few products that get a free case (displays as a kit for eventual inventory tracking).

I've got this in the ProductList_ItemDataBound function of my custom page (based on CategoryGridPage3.ascx)

Code: Select all

                
if (product.HasChoices)
                {
                    //int _ProductId = 0;
                    //Product _Product = null;
                    //Dictionary<int, int> _SelectedOptions = null;
                    //List<int> _SelectedKitProducts = null;
                    //BUILD PRODUCT ATTRIBUTES
                    ProductHelper.BuildProductOptions(product, itemTemplate4);
                    //BUILD PRODUCT CHOICES
                    ProductHelper.BuildProductChoices(product, itemTemplate4);
                    //BUILD KIT OPTIONS
                    ProductHelper.CategoryKitOptions(product, itemTemplate5);
                }
I'm using the AddtoCart user control as I don't want to add multiple products to the cart at once (it isn't how our customers purchase items) and I'm also displaying a More Info link.

The problem: Clicking Buy Now (add to cart uc) doesn't add kitted products or options to the cart, it still redirects to the product page. I want it to go straight to the basket. I know why this is happening but I'm not sure how to fix.

I've looked at the BuyProductDialog.ascx and I can see where the basket item builds the kit into the basket. Can I just add some of this code to the AddtoCart control? I also turned off the autopostback for the checkbox list because it was automatically unchecking as soon as a box was checked. Is there a way to get the price to work - add another updatePanel?

Any advice or direction to look in is appreciated. I think I saw jmstep was trying to do something similar but I'm not sure I understood that either. If I should move to that post let me know.

Thanks,
Dappy

Re: Display Kit Options on Category Pages

Posted: Tue Jun 16, 2009 8:18 am
by mazhar
The out of box control AddToCart wont work in this situation because that is built to take care that if some products has some choices with it then that should go to product details page first where it has it own code to add product to basket. Yes you are right you need to do something like BuyProductDialog control to add product directly to basket.

One possible solution could be to write a user control that could render a single product and contains add to basket logic that would directly add product to basket depedning upon user choices. Finally you put this control in category logic so that each category product is displayed by using this product.

Re: Display Kit Options on Category Pages

Posted: Tue Jun 16, 2009 8:49 am
by dappy2
So I could use a control similar to the BuyProductDialog within the repeater for the CategoryGrid?

I'm not too familiar with programming but I'm getting there. I had an AHA moment yesterday going through the ProductHelper.cs

Thanks,
Dappy

Re: Display Kit Options on Category Pages

Posted: Tue Jun 16, 2009 9:01 am
by mazhar
Yes. First create something to render a single product with add to cart support and then make category repeater repeat for all category products.

Re: Display Kit Options on Category Pages

Posted: Fri Jun 19, 2009 8:31 am
by kastnerd
This code could be usefull for me as well.