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

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

July 24, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento how to stop /checkout/onepage/success/ redirecting

Solving Magento Order Success Page Redirect Issue

Magento order success page
Fig 1. Default Magento onepage checkout success page

As a Magento developer, you might face the challenge of styling or debugging the order success page (/checkout/onepage/success/), only to find it redirecting due to the absence of an active session. This can be quite frustrating when trying to apply CSS changes or check JavaScript behavior. Let’s dive into how you can temporarily disable this redirect for testing purposes.

Understanding the Redirect Cause

The redirect issue arises from Magento’s Onepage Checkout logic. Once the order is placed successfully, Magento clears the checkout session and redirects the user to the success page. If no active order session exists (which happens during development when refreshing the page), Magento triggers an automatic redirect back to the checkout cart page.

Temporarily Disabling the Redirect

To temporarily disable this redirect behavior for testing and styling purposes:

  1. Navigate to your Magento root folder via FTP or SFTP.
  2. Locate the app/code/core/Mage/Checkout/controllers/OnepageController.php file.
  3. Open the file using a text editor.
// File: app/code/core/Mage/Checkout/controllers/OnepageController.php

public function successAction()
{
    // ...
    $this->getOnepage()->initOrder();
    if (!$order) {
        $this->_redirect('checkout/cart');
        return;
    }
    // ...
}
  1. Find the if (!$order) condition.
  2. Comment out or temporarily remove the redirect line:
// Remove or comment this line:
$this->_redirect('checkout/cart');

// Your code should look like this:
if (!$order) {
    // No redirect happens if no order is found
}
  1. Save your changes and upload the updated file to your Magento root folder.

Now, when you refresh the order success page during development, it will stay on the same page without triggering the automatic redirect back to the cart page. This allows for easier styling and debugging of the success page layout.

Important Note

Remember that this is only a temporary fix meant solely for development purposes. Don’t forget to restore the original file with the redirect logic before pushing your changes to production or staging environments. The redirect serves an important purpose in ensuring users return to the cart after a failed checkout process.

Conclusion: Enabling Development-Friendly Styling

By following these steps, you can now style and debug the Magento onepage checkout success page directly on the page itself during development. This change provides a better workflow for applying CSS changes, testing JavaScript interactions, and ensuring optimal user experience for your clients.

Don’t hesitate to visit Laravel Company for more in-depth guides and resources on Magento customization and optimization best practices.

Checkout Themes Orders Errors

Our network