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>

What mistake i have done


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.

  • on which file i have to edit – Magento 2 Nov 4 '15 at 8:49
  • do you have get any response from after addtocart? – Qaisar Satti Nov 4 '15 at 9:01
  • no i am asking which file i want to add the controllers – Magento 2 Nov 4 '15 at 9:20
  • in which you are adding the product into cart. there you get response either product added into cart or not. – Qaisar Satti Nov 4 '15 at 9:24
  • Check this --> totaltoys.com/fisher-price-babys-first-bl.html Insted of redirection i added into reload samepage it self – Magento 2 Nov 4 '15 at 9:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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