I included a link named track your order in footer. If user click this link without logged in, it should show error message like please login to track your order.
I'm new to magento please guide me to do this.
I included a link named track your order in footer. If user click this link without logged in, it should show error message like please login to track your order.
I'm new to magento please guide me to do this.
Added because this question appears in Google.
For a yellow "warning" message (the one you probably want for this purpose), use
Mage::getSingleton('core/session')->addNotice('Please log in to track your order');
For a green "success" message, use
Mage::getSingleton('core/session')->addSuccess('Tracking successful');
For a red "error" message, use
Mage::getSingleton('core/session')->addError('There was an error tracking your parcel');
- Set Your Message.
Mage::getSingleton("core/session")->addSuccess("Add success message");
Mage::getSingleton("core/session")->addError("Please login");
Mage::getSingleton("core/session")->addNotice("Add notification message");
- Display Your Message in Footer.
<?php echo $this->getChildHtml('global_messages'); ?>
3.Define Block in Layout. (Optional If use custom Extension Or not Defined)
<block type="core/messages" name="global_messages" as="global_messages"/>
Mage::getSingleton('core/session')->addSuccess('Success Message');
Mage::getSingleton('core/session')->addError('Error Message');
Mage::getSingleton('core/session')->addWarning('Warning Message');
Mage::getSingleton('core/session')->addNotice('Notice Message');