Magento how to stop / checkout / onepage / success / redirecting

I need to create a success page for a successful Magento /checkout/onepage/success/ , but since it redirects when there is no order session, I cannot refresh the page to check my changes!

Does anyone know how I can temporarily stop this redirect for testing purposes?

+7
source share
5 answers

You can change the file /app/code/core/Mage/Checkout/controllers/OnepageController.php . Change successAction to look like this:

  public function successAction() { /* $session = $this->getOnepage()->getCheckout(); if (!$session->getLastSuccessQuoteId()) { $this->_redirect('checkout/cart'); return; } $lastQuoteId = $session->getLastQuoteId(); $lastOrderId = $session->getLastOrderId(); $lastRecurringProfiles = $session->getLastRecurringProfileIds(); if (!$lastQuoteId || (!$lastOrderId && empty($lastRecurringProfiles))) { $this->_redirect('checkout/cart'); return; } $session->clear(); */ $this->loadLayout(); $this->_initLayoutMessages('checkout/session'); Mage::dispatchEvent('checkout_onepage_controller_success_action', array('order_ids' => array($lastOrderId))); $this->renderLayout(); } 

Remember to delete comments when done!

+24
source

Firefox will allow you to disable HTTP redirection, but you may need to temporarily hack the controller so that you stay on the page anyway.

0
source

I suggest replacing your successAction with this code:

 /** * Order success action */ public function successAction() { $session = $this->getOnepage()->getCheckout(); $session->setLastSuccessQuoteId(20); // <<< add your order entity ID $session->setLastQuoteId(20); // <<< add your order entity ID $session->setLastOrderId(20); // <<< add your order entity ID if (!$session->getLastSuccessQuoteId()) { $this->_redirect('checkout/cart'); return; } $lastQuoteId = $session->getLastQuoteId(); $lastOrderId = $session->getLastOrderId(); $lastRecurringProfiles = $session->getLastRecurringProfileIds(); if (!$lastQuoteId || (!$lastOrderId && empty($lastRecurringProfiles))) { $this->_redirect('checkout/cart'); return; } #$session->clear(); // <<< comment it $this->loadLayout(); $this->_initLayoutMessages('checkout/session'); Mage::dispatchEvent('checkout_onepage_controller_success_action', array('order_ids' => array($lastOrderId))); $this->renderLayout(); } 

Hi

0
source

Although code changes may be desirable, there is an extension for this:

https://www.yireo.com/blog/1672-testing-the-magento-checkout-success-page

Disclosure: I am by no means the / dev encoder, so the distribution route appeals to me (although it’s convenient for me to make these changes).

0
source

If someone searches for the same solution for Magento 2 to stop the redirect from the success page after the page reloads, here it is:

A quick and dirty debugging solution:

  • Open / vendor / magento / module -checkout / Controller / Onepage / Success.php
  • Comment code

/* if (!$this->_objectManager->get('Magento\Checkout\Model\Session\SuccessValidator')->isValid()) { return $this->resultRedirectFactory->create()->setPath('checkout/cart'); } $session->clearQuote(); */

The correct solution using the module can be found here https://gielberkers.com/style-checkoutonepagesuccess-page-magento-2/

0
source

All Articles