I wonder If there is any way to disable Add To Cart For selected category Products. I found the way to disable on the products behalf but didn't find any way to do with categories. Like I have a categories e.g...

Brands //Parent Category
  |-- Diamonds   //Child Category of Brands
  |-- Jewllery  //Child Category of Brands
  |-- Watches   // Child Category of Brands. Disable "add to cart" for this category products

2 Answers 2


I would have a product attribute that is an array of category ids (ie 23,33,45,12,34,56,) and in the product list/grid, check through the products attribute array to see if a match is made with the current category.

Get Current Category (at top of list.phtml (outside the foreach))

 $current_category = Mage::registry('current_category');
 //Used to check through each product attribute array
 $current_category_id = $current_category->getData('id');

Then in foreach product

$my_product_array = explode(",","".$_product->getMyAttribute()."");

if (in_array("".$current_category_id."", $my_product_array))
{$is_allowed =  'no';
$is_allowed =  'yes';

And wrap an if statement around the add to cart

if($is_allowed == 'no'){

//dont show cart button

}elseif($is_allowed == 'yes'){

//show cart button


Of course this wont stop a hard coded url request to add to cart

  • 1
    To stop a hard coded url request to add to cart you can hook up an observer to watch for products being added to the cart and cancel the action if it is necessary.
    – Vic
    Aug 25, 2015 at 23:27

Add below code to your theme template app/design/frontend/[Your-theme]/[your-package]/template/catalog/product/list.phtml

<?php if(Mage::registry('current_category')->getId() != ['Your-category-id]){?>
<button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
<?php } ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.