Kriuchko
1/9/2019 - 12:03 PM

Redirect after add to cart redirect product redirect custom redirect after add to cart

Magento 1 redirect after add to cart

app/code/core/Mage/Checkout/controllers/CartController.php
protected function _goBack

protected function _goBack()
{
  $returnUrl = $this->getRequest()->getParam('return_url');
  if ($returnUrl) {

      if (!$this->_isUrlInternal($returnUrl)) {
          throw new Mage_Exception('External urls redirect to "' . $returnUrl . '" denied!');
      }

      $this->_getSession()->getMessages(true);
      $this->getResponse()->setRedirect($returnUrl);
  } elseif (!Mage::getStoreConfig('checkout/cart/redirect_to_cart')
      && !$this->getRequest()->getParam('in_cart')
      && $backUrl = $this->_getRefererUrl()
  ) {
      $this->getResponse()->setRedirect($backUrl);
  } else {
      if (($this->getRequest()->getActionName() == 'add') && !$this->getRequest()->getParam('in_cart')) {
          $this->_getSession()->setContinueShoppingUrl($this->_getRefererUrl());
      }

      $variableHtml = Mage::getModel('core/variable')->loadByCode('add_to_cart_redirect')->getValue('html');

      if( $variableHtml and $this->getRequest()->getActionName() == 'add' ){
          $this->_redirect( $variableHtml );
      }else{
          $this->_redirect('checkout/cart');
      }

  }
  return $this;
}