1

Edit

Once we click on "ADD TO CART" in "My account" page and if we open any other pages like home page , catalog page, product page, i can see message there, but not displaying in My account page.

Edit end

In "My designs" section, Under My account we are displaying some products and gave an option for "Add to cart" and its working fine.

enter image description here

now i need to display message on top of the page after customer click on "Add to cart" similar to product view page :

enter image description here

For "Add to cart" button, i am trying same code that we are using in product view page, but its not displaying any message.

app/design/frontend/rwd/Stylebaby/template/example/example.phtml

<?php $collections = $this->getCollection(); ?> <?php $_product = $this->getProduct(); ?> <?php $buttonTitle = Mage::helper('core')->quoteEscape($this->__('Add to Cart')); ?> <?php foreach ($collections as $key => $product) { echo $product->getName().' <br>'; ?> <form action="<?php echo Mage::helper('checkout/cart')->getAddUrl($product);?>" method="post"> <div class="add-to-cart-buttons"> <button type="submit" title="<?php echo $buttonTitle ?>" class="button btn-cart" > <span><span> <?php echo $buttonTitle ?> </span></span> </button> <?php echo $this->getChildHtml('', true, true) ?> </div> </form> <hr style='display:inline-block; width:100%;'> <?php } ?> 

Edit

app/code/local/Amasty/Example/controllers/mydesigncontrollers.php - http://pastebin.com/rpjjMthf

0

2 Answers 2

1

To add messages on your page, you need to add Layout Message block on your controller. Here in your case, app/code/local/Amasty/Example/controllers/MyDesignController.php

public function indexAction() { if(!Mage::getSingleton('customer/session')->isLoggedIn()){ Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('customer/account/login')); } $this->loadLayout(); $this->_initLayoutMessages('checkout/session'); $this->renderLayout(); } 

And get Groped Html on top in your phtml, app/design/frontend/rwd/Stylebaby/template/example/example.phtml

<?php echo $this->getMessagesBlock()->getGroupedHtml() ?> 
0
2

try below code

<div id="messages_product_view"><?php echo $this->getMessagesBlock()->toHtml() ?></div> 

or

<div id="messages_product_view"><?php echo $this->getMessagesBlock()->getGroupedHtml() ?></div> 

add below code into your controller after load Layout

$this->_initLayoutMessages('checkout/session'); 
14
  • Thanks, i tried your code as here, but it didt worked for me, what wrong i am doing here : pastebin.com/FjiUx2tr Commented Mar 24, 2017 at 11:10
  • I edited question, when you get free time, please look once..... Commented Mar 24, 2017 at 11:47
  • after adding product to cart on which page it is redirecting? @BabyinMagento Commented Mar 24, 2017 at 13:02
  • it staying in same page, but not displaying any message in same page, but when i opened any other pages, its displaying message there..... Commented Mar 24, 2017 at 13:05
  • you are using Ajax ? @BabyinMagento Commented Mar 24, 2017 at 13:53

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.