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

I wrote these tutorials for myself in future when I forget for the next steps.
Search for a command to run...

I wrote these tutorials for myself in future when I forget for the next steps.
No comments yet. Be the first to comment.
When you provision an Ubuntu instance on Oracle Cloud, you'll notice something different from standard Ubuntu installations: the system uses iptables instead of ufw for firewall management. This disti

When developing web applications locally, HTTPS is often overlooked. Yet, modern browsers and APIs increasingly require secure connections—even in development. That’s where mkcert comes in: a simple t

Magento Commerce (EE) offers powerful features, but for many teams, Open Source (CE) is leaner, lighter, and more sustainable. If you're migrating from EE to CE, the Opengento downgrade tool provides a clean, scriptable way to remove proprietary modu...

If you’ve ever checked your Apache error logs and seen something like this: Code [core:error] (13)Permission denied: access to /robots.txt denied (filesystem path '/home/username/sites') because search permissions are missing on a component of the pa...

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.
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.
To bypass this, you can temporarily comment out the line that clears the quote in the Success controller.
bash
vendor/magento/module-checkout/Controller/Onepage/Success.php
Find the following line inside the execute() method:
php
$session->clearQuote();
Comment it out:
php
// $session->clearQuote();
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.
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.
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();
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?