Search code examples
customizationmagento-1.4magento-1.5magento

how to display a message on cart and checkout page for particular category product?


lets say i have a category "test" and its product "t1". IF i add this product to cart, it must show some message "my custom message". Also on checkout page, how can i do the same on payment step. i.e check if it is from category test then display this message ?

what i tried so far on cart page is this before form on cart.phtml:

$_catCollection = $this->getItem()->getProduct()->getCategoryCollection();

foreach ($_catCollection as $_category) {
  // do stuff with your Mage_Catalog_Model_Category
  print_r($_category);
}
?>

But getting this Fatal error: Call to a member function getProduct() on a non-object


Solution

  • Set up an attribute for each product that will contain your special message.

    Then you can maybe do something along the lines of:

     <?php foreach ($this->getItems() as $item) : ?>
          <?php  if ($item->getSpecialMessage) : ?>
               <?php echo $item->getSpecialMessage ?>
          <?php endif ?>
     <?php endforeach; ?>