Hide add to cart on grouped products....

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
8 years ago
I set up a store on 3.5 over a year ago and it shows the "from" price and a details button *only* on grouped products in the category and manufacturer pages, as well as search results. (but simple products have a price and Add to Cart buttons.) Now on 3.6 I cannot figure out how I did that. It shows the "from" price, add to cart button, and a details button on grouped products, and that is confusing and redundant. Any ideas?
8 years ago
You can't do it out of the box in 3.60 so you need to slightly modify the source code:
1. Add ProductType property to ProductOverviewModel
2. Fill it in PrepareProductOverviewModels method

We made steps described above for 3.80: Add product type property to product models (presentation layer)

3. And then use it in the _ProductBox view like this:


                @if (Model.ProductType == ProductType.GroupedProduct)
                {
                    <input type="button" value="@T("Products.Details")" class="button-1 product-box-detail-button" onclick="setLocation('@Url.RouteUrl("Product", new {SeName = Model.SeName})')"/>
                }
                else
                {
                    if (!Model.ProductPrice.DisableBuyButton)
                    {
                        var addToCartText = T("ShoppingCart.AddToCart").Text;
                        if (Model.ProductPrice.IsRental)
                        {
                            addToCartText = T("ShoppingCart.Rent").Text;
                        }
                        if (Model.ProductPrice.AvailableForPreOrder)
                        {
                            addToCartText = T("ShoppingCart.PreOrder").Text;
                        }
                        <input type="button" value="@(addToCartText)" class="button-2 product-box-add-to-cart-button" onclick="AjaxCart.addproducttocart_catalog('@addtocartlink');return false;"/>
                    }
                }
8 years ago
Thank you. So in 3.6 I can follow those steps for 3.8 in VS and recompile?
8 years ago
Nevermind.
8 years ago
preachur wrote:
Thank you. So in 3.6 I can follow those steps for 3.8 in VS and recompile?


Yes, you can.
8 years ago
...hmmm still getting an error on that solution.
8 years ago
Having wishlist, add to cart and details buttons that all do the same thing on grouped products in the category view is wacky.
7 years ago
What error do you got?

I forgot to clarify that you should add these lines instead of existing:

                @if (!Model.ProductPrice.DisableBuyButton)
                {
                    var addToCartText = T("ShoppingCart.AddToCart").Text;
                    if (Model.ProductPrice.IsRental)
                    {
                        addToCartText = T("ShoppingCart.Rent").Text;
                    }
                    if (Model.ProductPrice.AvailableForPreOrder)
                    {
                        addToCartText = T("ShoppingCart.PreOrder").Text;
                    }
                    <input type="button" value="@(addToCartText)" class="button-2 product-box-add-to-cart-button" onclick="AjaxCart.addproducttocart_catalog('@addtocartlink');return false;" />
                }
7 years ago
error CS0103: The name 'ProductType' does not exist in the current context
7 years ago
Did you do first two steps described here:


Mariann wrote:
You can't do it out of the box in 3.60 so you need to slightly modify the source code:
1. Add ProductType property to ProductOverviewModel
2. Fill it in PrepareProductOverviewModels method

We made steps described above for 3.80: Add product type property to product models (presentation layer)

3. And then use it in the _ProductBox view like this:


                @if (Model.ProductType == ProductType.GroupedProduct)
                {
                    <input type="button" value="@T("Products.Details")" class="button-1 product-box-detail-button" onclick="setLocation('@Url.RouteUrl("Product", new {SeName = Model.SeName})')"/>
                }
                else
                {
                    if (!Model.ProductPrice.DisableBuyButton)
                    {
                        var addToCartText = T("ShoppingCart.AddToCart").Text;
                        if (Model.ProductPrice.IsRental)
                        {
                            addToCartText = T("ShoppingCart.Rent").Text;
                        }
                        if (Model.ProductPrice.AvailableForPreOrder)
                        {
                            addToCartText = T("ShoppingCart.PreOrder").Text;
                        }
                        <input type="button" value="@(addToCartText)" class="button-2 product-box-add-to-cart-button" onclick="AjaxCart.addproducttocart_catalog('@addtocartlink');return false;"/>
                    }
                }


?
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.