Magento: Placing Order doesn't redirect to success page

Magento: Placing Order doesn't redirect to success page

July 28, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento: Placing Order doesn't redirect to success page

Solving Magento Order Placement Redirect Issues

Magento is an e-commerce platform that offers numerous features for managing online stores. However, sometimes users encounter issues like the order placement redirect not working properly. This post will guide you through identifying and resolving a common problem: when clicking “Place Order” in the checkout process doesn’t redirect to the success page in Magento.

Identifying the Issue

When you click the “Place Order” button during the final checkout step, instead of being redirected to a “Thank You” or order success page, the page remains static with all the products still visible. This issue can be visually represented as shown in this image: Checkout Page After Place Order Click.

Understanding the Controller

The primary logic for order placement redirection is handled by the onepageController.php file located under /Checkout/controllers/. The relevant method is successAction(), which is triggered when a successful order is placed.

Let’s analyze the provided controller code:

public function successAction()
{
    $session = $this->getOnepage()->getCheckout();
    // ... (other conditions)
    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();
}

Troubleshooting the Redirect Problem

The core issue lies in the redirect condition near the middle of the method. If the last order ID or recurring profile IDs are not set, it redirects back to the cart page instead of the success page.

To troubleshoot this:

  1. Check if the $lastOrderId is being set correctly before reaching this line: if (!$lastQuoteId || (!$lastOrderId && empty($lastRecurringProfiles))). Ensure that the order creation process is successful and that the ID is being stored in the session.

  2. Verify that no errors are occurring during the order placement process that might prevent the $lastOrderId from being set correctly.

Resolving the Redirect Issue

To resolve this issue, you can modify the redirect condition or adjust the order placement process:

Option 1: Modify the Controller Logic

You could modify the controller logic to handle cases where the lastOrderId is not available. For example, you might want to display a custom error message instead of redirecting back to the cart.

public function successAction()
{
    // ... (existing code)

    if (!$lastQuoteId || (!$lastOrderId && empty($lastRecurringProfiles))) {
        $this->getOnepage()->addError(Mage::helper('checkout')->__('An error occurred while processing your order. Please try again later.'));
        $this->renderLayout();
        return;
    }

    // ... (remaining code)
}

Option 2: Debug the Order Placement Process

If you believe the issue is with the order placement process rather than the controller logic, consider debugging to ensure that the lastOrderId is being set correctly. You can add log statements or use Magento’s built-in logging system to track the order creation process.

Conclusion

Resolving redirect issues in Magento requires a good understanding of the checkout process and the controllers involved. By analyzing the onepageController.php file, we can identify conditions that prevent the redirection to the success page.

To fix the issue:

  1. Troubleshoot the order placement process to ensure that the lastOrderId is being set correctly.
  2. Modify the controller logic if necessary to handle cases where the redirect condition fails.
  3. Consider adding custom error messages or using Magento’s built-in logging system for better debugging.

Remember to always backup any files before making changes and test thoroughly in a development environment before applying fixes to your live store.

For more detailed guides on Magento development, visit our blog at https://laravelcompany.com.

Checkout Catalog Security Themes

Our network