inhibiting 'add to cart' button in CategoryGridPage.aspx

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
ksolito
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 42
Joined: Tue Nov 25, 2008 3:16 pm

inhibiting 'add to cart' button in CategoryGridPage.aspx

Post by ksolito » Fri Jun 12, 2009 8:35 am

Using AC v7.0.2

We have some product items that are special order items in a category with stocked items. We want to all items in this specific category to have only the 'details' button and none displayed with the 'add to cart' button. This is for a single product category only, all other categories are to work normally. The active code is CategoryGridPage and it looks lke the logic for the button display is in AddToCartLink.aspx.cs, AddToCart(), about line 108:

if (product.HasChoices || product.UseVariablePrice)
{
//CANT ADD DIRECTLY TO BASKET, SEND TO MORE INFO
Response.Redirect(product.NavigateUrl);
}

I think I need to add a condition to test the Category ID for the product being displayed. My specific questions are:

1) Am I looking at the right place in the code?
2) Is the Category ID available for the product and how do I reference it if it is?

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

Re: inhibiting 'add to cart' button in CategoryGridPage.aspx

Post by mazhar » Fri Jun 12, 2009 8:51 am

Yes you need to update AddToCart control. Edit your AddToCart.ascx.cs file and update your Page_PreRender method as below

Code: Select all

protected void Page_PreRender(object sender, EventArgs e)
    {
        Product product = ProductDataSource.Load(_ProductId);
        if ((!Token.Instance.Store.Settings.ProductPurchasingDisabled) && (product != null) && (!product.DisablePurchase) && !product.HasChoices && !product.UseVariablePrice)
        {
            LT.Text = string.Format(LT.Text, product.Name);
            LI.AlternateText = string.Format(LI.AlternateText, product.Name);
        }
        else
        {
            AC.Visible = false;
        }

        if (product.Categories[0] == 3)
            AC.Visible = false;
        MoreDetailsLink.Visible = !AC.Visible;
        if (MoreDetailsLink.Visible) MoreDetailsLink.NavigateUrl = product.NavigateUrl;
        SaveCustomViewState();
    }
Where 3 is category id for which I want to hide add to cart option.

Post Reply