How to test or style the order success page?

You can temporarily hack the core while you are developing:

In /app/code/core/Mage/Checkout/controllers/OnepageController.php edit successAction().

Comment out the line $session->clear();. Now you can make one order and refresh the page as often as you like.

If you do not even want to make an order on each browser, for example when doing cross-browser testing, you also can just initialize the session every time.

Pick an order id and a quote id from the table sales_flat_order (fields: entity_id and quote_id). For example via:

SELECT entity_id as order_id, quote_id 
  FROM sales_flat_order ORDER BY entity_id DESC LIMIT 1;

Then change the beginning of the function as follows:

$session = $this->getOnepage()->getCheckout();

$session->setLastSuccessQuoteId(INSERT_QUOTE_ID);
$session->setLastQuoteId(INSERT_QUOTE_ID);
$session->setLastOrderId(INSERT_ORDER_ID);

and replaceINSERT_.... with the IDs.

Now you can always call checkout/onepage/success

While you are at it, you might want to test the failureAction() as well, in

/app/code/core/Mage/Checkout/controllers/OnepageController.php

The modified action would look like this

public function failureAction()
    {
        $session = $this->getOnepage()->getCheckout();

        $session->setLastSuccessQuoteId(INSERT_QUOTE_ID);
        $session->setLastQuoteId(INSERT_QUOTE_ID);
        $session->setLastOrderId(INSERT_ORDER_ID);

        $lastQuoteId = $this->getOnepage()->getCheckout()->getLastQuoteId();
        $lastOrderId = $this->getOnepage()->getCheckout()->getLastOrderId();

        if (!$lastQuoteId || !$lastOrderId) {
            $this->_redirect('checkout/cart');
            return;
        }

        $this->loadLayout();
        $this->renderLayout();
    }

Now you can always call checkout/onepage/failure


You need to modify the successAction() in

/app/code/core/Mage/Checkout/controllers/OnepageController.php

Modified action would 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();
    }

Hope I'm not too self-promoting, but I created a free extension that can be quickly installed in Magento, and allows you to preview the order success-page for any order - simply by accessing an URL: http://www.yireo.com/software/magento-extensions/checkout-tester