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?
inhibiting 'add to cart' button in CategoryGridPage.aspx
Re: inhibiting 'add to cart' button in CategoryGridPage.aspx
Yes you need to update AddToCart control. Edit your AddToCart.ascx.cs file and update your Page_PreRender method as below
Where 3 is category id for which I want to hide add to cart option.
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();
}