Magento – How to display Success Message

magento-1.9

I Have a form also it redirect to same page. I try to display Success message After Product add to the cart but it showing whenever i reload the page

  <form action="<?php echo Mage::helper('checkout/cart')->getAddUrl(Mage::registry('current_product')); ?>" method="post" id="seller_addtocart_form1" class="ma">
                                <input type="hidden" name="return_url" value="<?php echo $currentUrl =  Mage::helper('core/url')->getCurrentUrl();?>" />
                                <input type="hidden" value="<?php echo $seller->getMpassignproductId(); ?>" name="mpassignproduct_id" class="mpassignproduct_id"/>
    <?php echo Mage::getSingleton('core/session')->addSuccess('Success');?>

    <button id="<?php echo $seller->getMpassignproductId() ?>" class="button btn-cart customaddtocart" title="<?php echo $this->__('Add to Cart')?>" onclick="<?php echo $currentUrl = Mage::helper('core/url')->getCurrentUrl();?>">
<span><span><?php echo $this->__('Add to Bag')?></span></span></button><div><button class="button buy-now" onclick="location.href ='{{config path="web/secure/base_url"}}/checkout/cart/add?product=1&qty=1'">
<span><span>Buy Now</span></span></button></div>
</form>

What mistake i have done

Best Answer

Mage::getSingleton('core/session')->addSuccess('Success');
this will not show the message you are adding the success message in session. on the refresh the page it will show message.

for displaying the success you have to set response from controller to show message. follow that answer for ajax success message.

Related Topic