I am new to Magento. I have added a new controller to display "Hello world" and the theme used is 'base/default'. I have added a new category and a new product inside it, which are both showing up. However, when I add that product to cart by clicking Add to Cart, I get redirected to a new page which simply displays a lot of code, like this:-

{"product_name":"Rolex","message":"Rolex was added into cart.","update_blocks":[{"key":".block.block-cart","value":"<div class=\"block block-cart\">\n
Proceed to Checkout<\/span><\/span><\/button>\n<\/li>\n                                                            <li><a href=\"http:\/\/localhost\/magento\/index.php\/checkout\/multishipping\/\" title=\"Checkout with Multiple Addresses\">Checkout with Multiple Addresses<\/a>\n<\/li>\n                                        <\/ul>\n                    <\/div>\n    <\/div>\n<\/div>\n"}],"r":"success"}

This is the url I've been redirected to:-


Although this is happening, when I return to my homepage, it is seen that the product has been added to cart. What is happening and how can I fix it?


As per your code,you have using Ajax Cart and due to any conflation at JavaScript that addCart ajax request not working and from CartController.php 's function addAction, a json data after addto cart of a product.That means that you cannot cart using general page refresh and need to send request using Ajax

That addAction return update_blocks, cart page in Json format.In this case you need to remove json return from CartController file

| improve this answer | |
  • That worked like MAGIC :D . I had installed an AJAX cart extension during my initial days and forgot all about it. Now I disabled it and got the required output. I have no idea how you debugged it without even getting full code, could you point me in the right direction? Thanks a ton anyway :) – Ajay May 22 '15 at 5:54
  • you are welcome – Amit Bera May 22 '15 at 5:55
  • Im too curious to know, how did you realize that AJAX was working? did you find out from the URL? – Ajay May 22 '15 at 5:58
  • Hi @AmitBera can u tell me which code remove. so it's working fine for me.. – Nikul Jun 16 '17 at 9:22

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.