Magento 2 - How to Test Success Page Without Repeatedly Placing Orders

Testing the checkout success page in Magento 2 can be frustrating. By default, once an order is placed, Magento clears the quote session, meaning you can’t simply refresh or revisit the success page without going through the entire checkout process again.
For developers and testers, this slows down iteration when styling or debugging the success page. Fortunately, there’s a simple tweak you can apply to make testing much easier.
Why Magento Clears the Quote?
Magento’s checkout flow is designed to ensure that once an order is completed:
The quote session is cleared (
$session->clearQuote()).Customers don’t accidentally re-submit the same order.
The cart resets for a fresh shopping experience.
This is great for production, but not so convenient when you’re working on the success page design or functionality.
The Quick Solution
To bypass this, you can temporarily comment out the line that clears the quote in the Success controller.
File Location
bash
vendor/magento/module-checkout/Controller/Onepage/Success.php
Code Adjustment
Find the following line inside the execute() method:
php
$session->clearQuote();
Comment it out:
php
// $session->clearQuote();
What This Does
By commenting out this line:
The quote session remains intact after checkout.
You can revisit the success page multiple times without placing new orders.
It allows faster iteration when testing layout, custom blocks, or tracking scripts.
How to Access the Success Page
Once the quote isn’t cleared, you can directly access the success page by visiting:
Code
https://yourdomain.com/checkout/onepage/success/
This will display the last order’s success details without requiring a fresh checkout.
Important Notes
Do not keep this change in production. Clearing the quote is essential for preventing duplicate orders and ensuring a clean cart experience.
Treat this as a temporary development tweak only.
Once you’re done testing, restore the original line:
php
$session->clearQuote();
Conclusion
This small adjustment can save you significant time when working on Magento 2’s checkout success page. Instead of repeatedly placing test orders, you can comment out $session->clearQuote() and freely reload the success page until your design or functionality is perfected.
Would you like me to also add a step-by-step guide with screenshots (e.g., file path navigation, code snippet before/after) so your blog post feels more visual and beginner-friendly, or keep it concise and developer-focused?



