0

I am using magento 1.8. I am having custom add-to-cart button, that label is "Add to cart and continue shopping"

Magento have these both option seperatly, "Add-to-cart" and "continue Shopping" How can I combine both the option in single button or click. I mean when user clicks on "Add to cart and continue shopping" it need to add the product to cart and redirect to home page/product list page..

THANK YOU.

2 Answers 2

2

system->configuration->sales section ->checkout->shopping cart->After Adding a Product Redirect to Shopping Cart=no

mage->checkout->controllers->cartcontroller-> you need to work on addAction method (you can directly give $url=home url or product list url.and you need to override cartcontroller).

if (!$this->_getSession()->getNoCartRedirect(true)) {
                if (!$cart->getQuote()->getHasError()) {
                    $message = $this->__('%s was added to your shopping cart.', Mage::helper('core')->escapeHtml($product->getName()));
                    $this->_getSession()->addSuccess($message);
                }
                $this->_goBack();
            }

........... ....

$url = $this->_getSession()->getRedirectUrl(true);
            if ($url) {
                $this->getResponse()->setRedirect($url);
            } else {
                $this->_redirectReferer(Mage::helper('checkout/cart')->getCartUrl());
            }
2
  • I need to redirect after adding the product to cart
    – Charlie
    Jun 11, 2014 at 11:31
  • mage->checkout->controllers->cartcontroller->you need to work on addAction method ->if (!$this->_getSession()->getNoCartRedirect(true)) { if (!$cart->getQuote()->getHasError()) { $message = $this->__('%s was added to your shopping cart.', Mage::helper('core')->escapeHtml($product->getName())); $this->_getSession()->addSuccess($message); } $this->_goBack(); }
    – sivakumar
    Jun 11, 2014 at 11:37
2

I solved It, First add the product to cart

Mage::getModel("checkout/cart")->addProduct($_product)->save();

Then call URL where you need to redirect [Below I am redirecting to home page]

$url = Mage::getUrl('home');
echo $url

Thanks You lot, Guys

1
  • If this answer worked, please verify it. So that others should also know what actually helped, before reading all comments Jun 11, 2014 at 13:52

Your Answer

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

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