4

How can redirect to a CMS page when the "add to cart button" (on a product view page) is clicked?

I have already disabled the redirect to the cart page after the "add to cart" button is clicked. Now I need to know what code edits to make to direct the browser to a new page.

3 Answers 3

3

Edit template for product view page YOUR_THEME/template/catalog/product/view.phtml

Replace this:

<form action="<?php echo $this->getSubmitUrl($_product) ?>" method="post" id="product_addtocart_form"<?php if($_product->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>>

With this:

<form action="<?php echo $this->getSubmitUrl($_product, array('return_url' => 'YOUR CMS PAGE URL')) ?>" method="post" id="product_addtocart_form"<?php if($_product->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>>
1
  • How to redirect to previous page??
    – Magento 2
    Commented Sep 22, 2015 at 9:38
1

I would suggest listening to the event checkout_cart_add_product_complete. Here you can use the following code to set a return_url in an observer.

$observer->getRequest()->setParam('return_url', Mage::Helper('cms/page')->getPageUrl($page_id));
1
  • 1
    @Seabstien: It doesn't work for me. I have an error and report file contains : a:5:{i:0;s:41:"External urls redirect to "http:" denied!";i:1;s:1163:"#0 Any idea ? Commented Mar 11, 2014 at 9:04
0

i am facing issue when i add item to cart its redirect to cart page,

i have change the redirect to NO from admin but now its direct open checkout page i need it like this when i click the add to cart button it should added to mincart but not leave the product page, after adding when i click the cart from there i can use open cart button to open the cart page. thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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