How to test or style the order success page?

If I reload the checkout/onepage/success page, I am directed to the cart.

So, when debugging or styling the order success page, I always have to make a new order.

How can I do this more efficiently?

Solutions

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

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

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

Similar questions

Call to undefined method Learning\Test\Model\Resource\Test\Collection::getCollection() in Magento 2
I have created Magento 2 Test Module which is connected to DB, it is throwing error while fetching collection. Any Idea on this. Fatal error: Call to undefined method Learning\Test\Model\Resource\Test\Collection::create() in C:\xampp\htdocs\magento-2\app\code\Learning\Test\Block\Adminhtml\Test\Grid.php on line 40 here i'm giving Model and Block(Con...
Magento 2: Magento Test Framework(MTF) Detail Document for custom module functional test
How to create the functional test for custom module in magento 2. Magento team not given proper doc and not mentioned steps to create functional test for custom module. Any body know in this world ?
Unit Test or Integration Test for this kind of functions?
I have the following resolve function in one of my classes: In order to test it I have created the following test case: What could I assert there in order to do a proper unit testing? Should I do unit testing at all? I am not invoking any my own function, so maybe I can omit unit testing and perform only integration tests?
Notice: Undefined property: Test\Module\Block\StockLeft::$_registry in C:\xampp\htdocs\Magento2\app\code\Test\Module\Block\StockLeft.php on line 28
I am creating a module that show the product stock item dynamically, but it is giving error "Parse error: syntax error, unexpected ':', expecting ')' in C:\xampp\htdocs\magento2.3.3\app\code\Test\Module\Block\StockLeft.php on line 31" StockLeft.php Template : stockleft.phtml Layout : catalog_product_view.xml
ERROR:iDEAL test bank: couldn't process your test payment
I integrated mollie iDeal Payment module in Magento 1.7.0. When I enable the test mode in the Mollie-account from Magento admin config, I see only the TBM Bank (testbank) as an option. When I select this I see following error: iDEAL test bank: couldn't process your test payment: Aww man! I could not process the payment you tried to set up for testi...
"Success page" text translation on success page
I can't find anywhere, where I can translate "Success Page" text - https://www.dropbox.com/s/vsfwyysmts4h4by/Screenshot%202018-03-13%2007.25.45.png?dl=0 Can anyone help me?

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.