How to test or style the order success page?How can I test an Event Observer that will run when an Order is Purchased?Generate one click test buy for develomentDisplay Message On Thank You Page If Shipping Method Is Equal ToMagento Success page, only half or less being reported in Google AnalyticsWhat class do I override (when utilizing SMTPPro) in order to conditionally log but not send emails to a list of recipients?Retrieving order detail on magento multiple address checkoutPlace Order button doesn't go to success/confirmation page? (1.9.1.0)How to add order summary to checkout success page?Success page get customer name and order idMagento 1.9.2.4 - Place Order not go success pageCustomer can open success page with parameters in URL, causing duplicate transactions in analyticsMagento 2 - redirect to final checkout page (checkout success/failed)Magento 2 : How to load the order success pageMagento 2 How to reload Order Summary SectionMagento2 How to reload checkout page summary?
Can you grapple/shove with the Hunter Ranger's Whirlwind Attack?
Is it appropriate for a prospective landlord to ask me for my credit report?
The logic of invoking virtual functions is not clear (or it is method hiding?)
What is the difference between a premise and an assumption in logic?
Would combining A* with a flocking algorithm be too performance-heavy?
What is the improvement of the "legally binding commitment" proposed by Boris Johnson over the existing "backstop"?
Why my earth simulation is slower than the reality?
Does Git delete empty folders?
How big would a Daddy Longlegs Spider need to be to kill an average Human?
Why don't politicians push for fossil fuel reduction by pointing out their scarcity?
Can you feel passing through the sound barrier in an F-16?
Taking out number of subarrays from an array which contains all the distinct elements of that array
Can we save the word "unique"?
Overwrite file only if data
Is refusing to concede in the face of an unstoppable Nexus combo punishable?
Ask for a paid taxi in order to arrive as early as possible for an interview within the city
Why doesn't the Falcon-9 first stage use three legs to land?
How can I support the recycling, but not the new production of aluminum?
How to organize ideas to start writing a novel?
How to compare two different formulations of a problem?
Dark side of an exoplanet - if it was earth-like would its surface light be detectable?
Vacuum collapse -- why do strong metals implode but glass doesn't?
Most practical knots for hitching a line to an object while keeping the bitter end as tight as possible, without sag?
Have only girls been born for a long time in this village?
How to test or style the order success page?
How can I test an Event Observer that will run when an Order is Purchased?Generate one click test buy for develomentDisplay Message On Thank You Page If Shipping Method Is Equal ToMagento Success page, only half or less being reported in Google AnalyticsWhat class do I override (when utilizing SMTPPro) in order to conditionally log but not send emails to a list of recipients?Retrieving order detail on magento multiple address checkoutPlace Order button doesn't go to success/confirmation page? (1.9.1.0)How to add order summary to checkout success page?Success page get customer name and order idMagento 1.9.2.4 - Place Order not go success pageCustomer can open success page with parameters in URL, causing duplicate transactions in analyticsMagento 2 - redirect to final checkout page (checkout success/failed)Magento 2 : How to load the order success pageMagento 2 How to reload Order Summary SectionMagento2 How to reload checkout page summary?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
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?
checkout development
add a comment |
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?
checkout development
2
This question created varied answers which are all full of "win". Anyone visiting here should peruse all the answers.
– Chris K
Nov 13 '14 at 21:05
add a comment |
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?
checkout development
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?
checkout development
checkout development
asked Feb 19 '13 at 11:10
AlexAlex
9,63417 gold badges58 silver badges118 bronze badges
9,63417 gold badges58 silver badges118 bronze badges
2
This question created varied answers which are all full of "win". Anyone visiting here should peruse all the answers.
– Chris K
Nov 13 '14 at 21:05
add a comment |
2
This question created varied answers which are all full of "win". Anyone visiting here should peruse all the answers.
– Chris K
Nov 13 '14 at 21:05
2
2
This question created varied answers which are all full of "win". Anyone visiting here should peruse all the answers.
– Chris K
Nov 13 '14 at 21:05
This question created varied answers which are all full of "win". Anyone visiting here should peruse all the answers.
– Chris K
Nov 13 '14 at 21:05
add a comment |
8 Answers
8
active
oldest
votes
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
Now you can always call checkout/onepage/failure
Fixes this your problem? Please mark it as solution.
– Fabian Blechschmidt
Mar 25 '13 at 7:59
3
I've tested both Jisse Reitsma's Yireo Checkout Tester and this method. While the module is the easiest way, I found it to be not 100% compatible with our theme and payment module, resulting in a different styling than the original succes page. While requiring to modify the core this method however worked like a charm. Note: the answer is missing the file you need to edit, which is /app/code/core/Mage/Checkout/controllers/OnepageController.php
– Ottonet
Jun 20 '15 at 22:19
For people that would like to do the same in M2 you can comment lines 19 to 22 invendormagentomodule-checkoutControllerOnepageSuccess.php
– Dynomite
Mar 13 '17 at 12:27
add a comment |
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
3
But then$lastOrderId
is not defined which would leat to a notice and to could lead to side effects in the template.
– Alex
Feb 19 '13 at 11:55
1
I've had success just by commenting out the $session->clear(); The only thing I lose is any notices/messages added such as TBT/Rewards Notices/Messages added via observer. Leaving the code in a override module, which is .gitignored so never deployed.
– Barry Carlyon
Jul 28 '14 at 9:10
add a comment |
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
add a comment |
I think it's better to just comment $session->clear(); and add products manually, that worked for me but commenting the whole action gave me syntax errors.
add a comment |
For Magento 2:
If you want to style or customize in success page after order success page redirects to cart page.
Now solution is here:
Go To vendor/magento/module-checkout/Controller/Onepage
open Success.php
File.
In this file, you see Below Code
if (!$this->_objectManager->get('MagentoCheckoutModelSessionSuccessValidator')->isValid())
return $this->resultRedirectFactory->create()->setPath('checkout/cart');
Just comment on this code and your problem is solved. After comment this you don't redirect to cart page.
add a comment |
Instead of sending out emails from local/development copy you can dump the content of the email to a file and then just see locally, which in my opinion will be really handy. Here's how that can be acheived. First all the emails are sent from
Mage_Core_Model_Email_Template::send($email, $name = null, array $variables = array())
Find that, and add the following lines.
$this->setUseAbsoluteLinks(true);
$text = $this->getProcessedTemplate($variables, true);
if($this->isPlain())
$mail->setBodyText($text);
else
$mail->setBodyHTML($text);
// Added Code //
$filePath = Mage::getBaseDir() . DS . 'email.html';
Mage::log($filePath);
file_put_contents($filePath, $text);
// Added Code Ends //
$mail->setSubject('=?utf-8?B?' . base64_encode($this->getProcessedTemplateSubject($variables)) . '?=');
$mail->setFrom($this->getSenderEmail(), $this->getSenderName());
After this after you create any order an email.html will be created in the Magento document root and you can open that in browser to see the output.
Next, to send/re-send any order emails you can just log in admin and for each order there is Send Email button which will trigger this script and you can see the newly changed template written in the same file. I think this is one of the best way to see order or any other emails.
Please note to remove the added code when you are done.
add a comment |
You have to update code:
/app/code/core/Mage/Checkout/controllers/OnepageController.php
Update function:
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
Just comment:
//$session->clear();
add a comment |
Magento 2
As another answer notes, you can comment out the redirect in MagentoCheckoutControllerOnepageSuccess::execute
and force the checkout success page to load. But when the block, MagentoCheckoutBlockOnepageSuccess
, loads no order data will be present because MagentoCheckoutModelSession::getLastRealOrder
won't return an order. A better options would be an after interceptor on the controller class's execute method, where you can set a value for lastRealOrderId
in the checkout session.
This approach also provides an opportunity to dispatch the checkout_onepage_controller_success_action
event with your desired order. The event will trigger the observers MagentoGoogleAdwordsObserverSetConversionValueObserver
and MagentoGoogleAnalyticsObserverSetGoogleAnalyticsOnOrderSuccessPageViewObserver
with your test data.
The following is a fairly basic module creating the interceptor described above and allows setting the order by appending an order
query parameter with the desired increment id to the success page url. It currently won't work the the multishipping success route. It can be downloaded on github: https://github.com/pmclain/magento2-successtest
app/code/Pmclain/SuccessTest/etc/frontend/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="MagentoCheckoutControllerOnepageSuccess">
<plugin name="pmclain_successtest_checkout_controller_onepage_success"
type="PmclainSuccessTestPluginSuccess"
sortOrder="10" />
</type>
</config>
app/code/Pmclain/SuccessTest/Plugin/Success.php
<?php
namespace PmclainSuccessTestPlugin;
use MagentoFrameworkEventManagerInterface;
use MagentoFrameworkViewResultPageFactory;
use MagentoFrameworkAppConfigScopeConfigInterface;
use MagentoStoreModelScopeInterface;
use MagentoCheckoutModelSession;
use MagentoSalesModelOrderFactory;
use MagentoSalesModelOrder;
class Success
/** @var ManagerInterface */
protected $_eventManager;
/** @var PageFactory */
protected $_resultPageFactory;
/** @var ScopeConfigInterface */
protected $_scopeConfig;
/** @var OrderFactory */
protected $_orderFactory;
/** @var Order */
protected $_order;
/** @var Session */
protected $_checkoutSession;
/**
* Success constructor.
* @param ManagerInterface $eventManager
* @param PageFactory $resultPageFactory
* @param ScopeConfigInterface $scopeConfig
* @param OrderFactory $orderFactory
* @param Session $session
*/
public function __construct(
ManagerInterface $eventManager,
PageFactory $resultPageFactory,
ScopeConfigInterface $scopeConfig,
OrderFactory $orderFactory,
Session $session
)
$this->_eventManager = $eventManager;
$this->_resultPageFactory = $resultPageFactory;
$this->_scopeConfig = $scopeConfig;
$this->_orderFactory = $orderFactory;
$this->_checkoutSession = $session;
/**
* @param MagentoCheckoutControllerOnepageSuccess $subject
* @param $result
* @return MagentoFrameworkViewResultPage
*/
public function afterExecute(MagentoCheckoutControllerOnepageSuccess $subject, $result)
if (!$this->_isEnabled())
return $result;
$order = $this->_getTestOrder($subject->getRequest()->getParam('order'));
if (!$order->getId())
return $result;
$this->_checkoutSession->setLastRealOrderId($order->getIncrementId());
$resultPage = $this->_resultPageFactory->create();
$this->_eventManager->dispatch(
'checkout_onepage_controller_success_action',
['order_ids' => [$order->getId()]]
);
return $resultPage;
/**
* @return bool
*/
protected function _isEnabled()
if ($this->_scopeConfig->getValue('dev/debug/success_test', ScopeInterface::SCOPE_STORE))
return true;
return false;
/**
* @param $incrementId string
app/code/Pmclain/SuccessTest/etc/adminhtml/system.xml
Below adds admin panel options to enable/disable the interceptor.
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
<section id="dev">
<group id="debug">
<field id="success_test" translate="label" type="select" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Enable Checkout Success Page Testing</label>
<source_model>MagentoConfigModelConfigSourceYesno</source_model>
</field>
</group>
</section>
</system>
</config>
app/code/Pmclain/SuccessTest/etc/config.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
<default>
<dev>
<debug>
<success_test>0</success_test>
</debug>
</dev>
</default>
</config>
app/code/Pmclain/SuccessTest/etc/module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Pmclain_SuccessTest" setup_version="0.0.1">
<sequence>
<module name="Magento_Backend" />
<module name="Magento_Checkout" />
</sequence>
</module>
</config>
app/code/Pmclain/SuccessTest/resgistration.php
<?php
MagentoFrameworkComponentComponentRegistrar::register(
MagentoFrameworkComponentComponentRegistrar::MODULE,
'Pmclain_SuccessTest',
__DIR__
);
add a comment |
protected by Community♦ Nov 4 '15 at 8:15
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
8 Answers
8
active
oldest
votes
8 Answers
8
active
oldest
votes
active
oldest
votes
active
oldest
votes
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
Now you can always call checkout/onepage/failure
Fixes this your problem? Please mark it as solution.
– Fabian Blechschmidt
Mar 25 '13 at 7:59
3
I've tested both Jisse Reitsma's Yireo Checkout Tester and this method. While the module is the easiest way, I found it to be not 100% compatible with our theme and payment module, resulting in a different styling than the original succes page. While requiring to modify the core this method however worked like a charm. Note: the answer is missing the file you need to edit, which is /app/code/core/Mage/Checkout/controllers/OnepageController.php
– Ottonet
Jun 20 '15 at 22:19
For people that would like to do the same in M2 you can comment lines 19 to 22 invendormagentomodule-checkoutControllerOnepageSuccess.php
– Dynomite
Mar 13 '17 at 12:27
add a comment |
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
Now you can always call checkout/onepage/failure
Fixes this your problem? Please mark it as solution.
– Fabian Blechschmidt
Mar 25 '13 at 7:59
3
I've tested both Jisse Reitsma's Yireo Checkout Tester and this method. While the module is the easiest way, I found it to be not 100% compatible with our theme and payment module, resulting in a different styling than the original succes page. While requiring to modify the core this method however worked like a charm. Note: the answer is missing the file you need to edit, which is /app/code/core/Mage/Checkout/controllers/OnepageController.php
– Ottonet
Jun 20 '15 at 22:19
For people that would like to do the same in M2 you can comment lines 19 to 22 invendormagentomodule-checkoutControllerOnepageSuccess.php
– Dynomite
Mar 13 '17 at 12:27
add a comment |
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
Now you can always call checkout/onepage/failure
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
Now you can always call checkout/onepage/failure
edited Jun 2 '16 at 13:02
Pim Schaaf
1115 bronze badges
1115 bronze badges
answered Feb 19 '13 at 11:13
AlexAlex
9,63417 gold badges58 silver badges118 bronze badges
9,63417 gold badges58 silver badges118 bronze badges
Fixes this your problem? Please mark it as solution.
– Fabian Blechschmidt
Mar 25 '13 at 7:59
3
I've tested both Jisse Reitsma's Yireo Checkout Tester and this method. While the module is the easiest way, I found it to be not 100% compatible with our theme and payment module, resulting in a different styling than the original succes page. While requiring to modify the core this method however worked like a charm. Note: the answer is missing the file you need to edit, which is /app/code/core/Mage/Checkout/controllers/OnepageController.php
– Ottonet
Jun 20 '15 at 22:19
For people that would like to do the same in M2 you can comment lines 19 to 22 invendormagentomodule-checkoutControllerOnepageSuccess.php
– Dynomite
Mar 13 '17 at 12:27
add a comment |
Fixes this your problem? Please mark it as solution.
– Fabian Blechschmidt
Mar 25 '13 at 7:59
3
I've tested both Jisse Reitsma's Yireo Checkout Tester and this method. While the module is the easiest way, I found it to be not 100% compatible with our theme and payment module, resulting in a different styling than the original succes page. While requiring to modify the core this method however worked like a charm. Note: the answer is missing the file you need to edit, which is /app/code/core/Mage/Checkout/controllers/OnepageController.php
– Ottonet
Jun 20 '15 at 22:19
For people that would like to do the same in M2 you can comment lines 19 to 22 invendormagentomodule-checkoutControllerOnepageSuccess.php
– Dynomite
Mar 13 '17 at 12:27
Fixes this your problem? Please mark it as solution.
– Fabian Blechschmidt
Mar 25 '13 at 7:59
Fixes this your problem? Please mark it as solution.
– Fabian Blechschmidt
Mar 25 '13 at 7:59
3
3
I've tested both Jisse Reitsma's Yireo Checkout Tester and this method. While the module is the easiest way, I found it to be not 100% compatible with our theme and payment module, resulting in a different styling than the original succes page. While requiring to modify the core this method however worked like a charm. Note: the answer is missing the file you need to edit, which is /app/code/core/Mage/Checkout/controllers/OnepageController.php
– Ottonet
Jun 20 '15 at 22:19
I've tested both Jisse Reitsma's Yireo Checkout Tester and this method. While the module is the easiest way, I found it to be not 100% compatible with our theme and payment module, resulting in a different styling than the original succes page. While requiring to modify the core this method however worked like a charm. Note: the answer is missing the file you need to edit, which is /app/code/core/Mage/Checkout/controllers/OnepageController.php
– Ottonet
Jun 20 '15 at 22:19
For people that would like to do the same in M2 you can comment lines 19 to 22 in
vendormagentomodule-checkoutControllerOnepageSuccess.php
– Dynomite
Mar 13 '17 at 12:27
For people that would like to do the same in M2 you can comment lines 19 to 22 in
vendormagentomodule-checkoutControllerOnepageSuccess.php
– Dynomite
Mar 13 '17 at 12:27
add a comment |
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
3
But then$lastOrderId
is not defined which would leat to a notice and to could lead to side effects in the template.
– Alex
Feb 19 '13 at 11:55
1
I've had success just by commenting out the $session->clear(); The only thing I lose is any notices/messages added such as TBT/Rewards Notices/Messages added via observer. Leaving the code in a override module, which is .gitignored so never deployed.
– Barry Carlyon
Jul 28 '14 at 9:10
add a comment |
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
3
But then$lastOrderId
is not defined which would leat to a notice and to could lead to side effects in the template.
– Alex
Feb 19 '13 at 11:55
1
I've had success just by commenting out the $session->clear(); The only thing I lose is any notices/messages added such as TBT/Rewards Notices/Messages added via observer. Leaving the code in a override module, which is .gitignored so never deployed.
– Barry Carlyon
Jul 28 '14 at 9:10
add a comment |
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
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
answered Feb 19 '13 at 11:16
blakcapsblakcaps
9484 gold badges26 silver badges55 bronze badges
9484 gold badges26 silver badges55 bronze badges
3
But then$lastOrderId
is not defined which would leat to a notice and to could lead to side effects in the template.
– Alex
Feb 19 '13 at 11:55
1
I've had success just by commenting out the $session->clear(); The only thing I lose is any notices/messages added such as TBT/Rewards Notices/Messages added via observer. Leaving the code in a override module, which is .gitignored so never deployed.
– Barry Carlyon
Jul 28 '14 at 9:10
add a comment |
3
But then$lastOrderId
is not defined which would leat to a notice and to could lead to side effects in the template.
– Alex
Feb 19 '13 at 11:55
1
I've had success just by commenting out the $session->clear(); The only thing I lose is any notices/messages added such as TBT/Rewards Notices/Messages added via observer. Leaving the code in a override module, which is .gitignored so never deployed.
– Barry Carlyon
Jul 28 '14 at 9:10
3
3
But then
$lastOrderId
is not defined which would leat to a notice and to could lead to side effects in the template.– Alex
Feb 19 '13 at 11:55
But then
$lastOrderId
is not defined which would leat to a notice and to could lead to side effects in the template.– Alex
Feb 19 '13 at 11:55
1
1
I've had success just by commenting out the $session->clear(); The only thing I lose is any notices/messages added such as TBT/Rewards Notices/Messages added via observer. Leaving the code in a override module, which is .gitignored so never deployed.
– Barry Carlyon
Jul 28 '14 at 9:10
I've had success just by commenting out the $session->clear(); The only thing I lose is any notices/messages added such as TBT/Rewards Notices/Messages added via observer. Leaving the code in a override module, which is .gitignored so never deployed.
– Barry Carlyon
Jul 28 '14 at 9:10
add a comment |
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
add a comment |
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
add a comment |
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
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
edited Oct 30 '18 at 12:01
Teja Bhagavan Kollepara
3,0504 gold badges21 silver badges51 bronze badges
3,0504 gold badges21 silver badges51 bronze badges
answered Mar 12 '14 at 8:50
Jisse ReitsmaJisse Reitsma
9448 silver badges17 bronze badges
9448 silver badges17 bronze badges
add a comment |
add a comment |
I think it's better to just comment $session->clear(); and add products manually, that worked for me but commenting the whole action gave me syntax errors.
add a comment |
I think it's better to just comment $session->clear(); and add products manually, that worked for me but commenting the whole action gave me syntax errors.
add a comment |
I think it's better to just comment $session->clear(); and add products manually, that worked for me but commenting the whole action gave me syntax errors.
I think it's better to just comment $session->clear(); and add products manually, that worked for me but commenting the whole action gave me syntax errors.
answered Jun 18 '13 at 8:07
Farzan BalkaniFarzan Balkani
1413 bronze badges
1413 bronze badges
add a comment |
add a comment |
For Magento 2:
If you want to style or customize in success page after order success page redirects to cart page.
Now solution is here:
Go To vendor/magento/module-checkout/Controller/Onepage
open Success.php
File.
In this file, you see Below Code
if (!$this->_objectManager->get('MagentoCheckoutModelSessionSuccessValidator')->isValid())
return $this->resultRedirectFactory->create()->setPath('checkout/cart');
Just comment on this code and your problem is solved. After comment this you don't redirect to cart page.
add a comment |
For Magento 2:
If you want to style or customize in success page after order success page redirects to cart page.
Now solution is here:
Go To vendor/magento/module-checkout/Controller/Onepage
open Success.php
File.
In this file, you see Below Code
if (!$this->_objectManager->get('MagentoCheckoutModelSessionSuccessValidator')->isValid())
return $this->resultRedirectFactory->create()->setPath('checkout/cart');
Just comment on this code and your problem is solved. After comment this you don't redirect to cart page.
add a comment |
For Magento 2:
If you want to style or customize in success page after order success page redirects to cart page.
Now solution is here:
Go To vendor/magento/module-checkout/Controller/Onepage
open Success.php
File.
In this file, you see Below Code
if (!$this->_objectManager->get('MagentoCheckoutModelSessionSuccessValidator')->isValid())
return $this->resultRedirectFactory->create()->setPath('checkout/cart');
Just comment on this code and your problem is solved. After comment this you don't redirect to cart page.
For Magento 2:
If you want to style or customize in success page after order success page redirects to cart page.
Now solution is here:
Go To vendor/magento/module-checkout/Controller/Onepage
open Success.php
File.
In this file, you see Below Code
if (!$this->_objectManager->get('MagentoCheckoutModelSessionSuccessValidator')->isValid())
return $this->resultRedirectFactory->create()->setPath('checkout/cart');
Just comment on this code and your problem is solved. After comment this you don't redirect to cart page.
edited Aug 8 at 17:33
Andhi Irawan
4791 gold badge8 silver badges20 bronze badges
4791 gold badge8 silver badges20 bronze badges
answered Jun 22 '17 at 8:55
NikulNikul
7651 gold badge11 silver badges22 bronze badges
7651 gold badge11 silver badges22 bronze badges
add a comment |
add a comment |
Instead of sending out emails from local/development copy you can dump the content of the email to a file and then just see locally, which in my opinion will be really handy. Here's how that can be acheived. First all the emails are sent from
Mage_Core_Model_Email_Template::send($email, $name = null, array $variables = array())
Find that, and add the following lines.
$this->setUseAbsoluteLinks(true);
$text = $this->getProcessedTemplate($variables, true);
if($this->isPlain())
$mail->setBodyText($text);
else
$mail->setBodyHTML($text);
// Added Code //
$filePath = Mage::getBaseDir() . DS . 'email.html';
Mage::log($filePath);
file_put_contents($filePath, $text);
// Added Code Ends //
$mail->setSubject('=?utf-8?B?' . base64_encode($this->getProcessedTemplateSubject($variables)) . '?=');
$mail->setFrom($this->getSenderEmail(), $this->getSenderName());
After this after you create any order an email.html will be created in the Magento document root and you can open that in browser to see the output.
Next, to send/re-send any order emails you can just log in admin and for each order there is Send Email button which will trigger this script and you can see the newly changed template written in the same file. I think this is one of the best way to see order or any other emails.
Please note to remove the added code when you are done.
add a comment |
Instead of sending out emails from local/development copy you can dump the content of the email to a file and then just see locally, which in my opinion will be really handy. Here's how that can be acheived. First all the emails are sent from
Mage_Core_Model_Email_Template::send($email, $name = null, array $variables = array())
Find that, and add the following lines.
$this->setUseAbsoluteLinks(true);
$text = $this->getProcessedTemplate($variables, true);
if($this->isPlain())
$mail->setBodyText($text);
else
$mail->setBodyHTML($text);
// Added Code //
$filePath = Mage::getBaseDir() . DS . 'email.html';
Mage::log($filePath);
file_put_contents($filePath, $text);
// Added Code Ends //
$mail->setSubject('=?utf-8?B?' . base64_encode($this->getProcessedTemplateSubject($variables)) . '?=');
$mail->setFrom($this->getSenderEmail(), $this->getSenderName());
After this after you create any order an email.html will be created in the Magento document root and you can open that in browser to see the output.
Next, to send/re-send any order emails you can just log in admin and for each order there is Send Email button which will trigger this script and you can see the newly changed template written in the same file. I think this is one of the best way to see order or any other emails.
Please note to remove the added code when you are done.
add a comment |
Instead of sending out emails from local/development copy you can dump the content of the email to a file and then just see locally, which in my opinion will be really handy. Here's how that can be acheived. First all the emails are sent from
Mage_Core_Model_Email_Template::send($email, $name = null, array $variables = array())
Find that, and add the following lines.
$this->setUseAbsoluteLinks(true);
$text = $this->getProcessedTemplate($variables, true);
if($this->isPlain())
$mail->setBodyText($text);
else
$mail->setBodyHTML($text);
// Added Code //
$filePath = Mage::getBaseDir() . DS . 'email.html';
Mage::log($filePath);
file_put_contents($filePath, $text);
// Added Code Ends //
$mail->setSubject('=?utf-8?B?' . base64_encode($this->getProcessedTemplateSubject($variables)) . '?=');
$mail->setFrom($this->getSenderEmail(), $this->getSenderName());
After this after you create any order an email.html will be created in the Magento document root and you can open that in browser to see the output.
Next, to send/re-send any order emails you can just log in admin and for each order there is Send Email button which will trigger this script and you can see the newly changed template written in the same file. I think this is one of the best way to see order or any other emails.
Please note to remove the added code when you are done.
Instead of sending out emails from local/development copy you can dump the content of the email to a file and then just see locally, which in my opinion will be really handy. Here's how that can be acheived. First all the emails are sent from
Mage_Core_Model_Email_Template::send($email, $name = null, array $variables = array())
Find that, and add the following lines.
$this->setUseAbsoluteLinks(true);
$text = $this->getProcessedTemplate($variables, true);
if($this->isPlain())
$mail->setBodyText($text);
else
$mail->setBodyHTML($text);
// Added Code //
$filePath = Mage::getBaseDir() . DS . 'email.html';
Mage::log($filePath);
file_put_contents($filePath, $text);
// Added Code Ends //
$mail->setSubject('=?utf-8?B?' . base64_encode($this->getProcessedTemplateSubject($variables)) . '?=');
$mail->setFrom($this->getSenderEmail(), $this->getSenderName());
After this after you create any order an email.html will be created in the Magento document root and you can open that in browser to see the output.
Next, to send/re-send any order emails you can just log in admin and for each order there is Send Email button which will trigger this script and you can see the newly changed template written in the same file. I think this is one of the best way to see order or any other emails.
Please note to remove the added code when you are done.
answered Dec 31 '13 at 7:08
Subesh PokhrelSubesh Pokhrel
6815 silver badges10 bronze badges
6815 silver badges10 bronze badges
add a comment |
add a comment |
You have to update code:
/app/code/core/Mage/Checkout/controllers/OnepageController.php
Update function:
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
Just comment:
//$session->clear();
add a comment |
You have to update code:
/app/code/core/Mage/Checkout/controllers/OnepageController.php
Update function:
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
Just comment:
//$session->clear();
add a comment |
You have to update code:
/app/code/core/Mage/Checkout/controllers/OnepageController.php
Update function:
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
Just comment:
//$session->clear();
You have to update code:
/app/code/core/Mage/Checkout/controllers/OnepageController.php
Update function:
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
Just comment:
//$session->clear();
answered Aug 3 '17 at 14:27
Ravi SoniRavi Soni
1,2266 silver badges19 bronze badges
1,2266 silver badges19 bronze badges
add a comment |
add a comment |
Magento 2
As another answer notes, you can comment out the redirect in MagentoCheckoutControllerOnepageSuccess::execute
and force the checkout success page to load. But when the block, MagentoCheckoutBlockOnepageSuccess
, loads no order data will be present because MagentoCheckoutModelSession::getLastRealOrder
won't return an order. A better options would be an after interceptor on the controller class's execute method, where you can set a value for lastRealOrderId
in the checkout session.
This approach also provides an opportunity to dispatch the checkout_onepage_controller_success_action
event with your desired order. The event will trigger the observers MagentoGoogleAdwordsObserverSetConversionValueObserver
and MagentoGoogleAnalyticsObserverSetGoogleAnalyticsOnOrderSuccessPageViewObserver
with your test data.
The following is a fairly basic module creating the interceptor described above and allows setting the order by appending an order
query parameter with the desired increment id to the success page url. It currently won't work the the multishipping success route. It can be downloaded on github: https://github.com/pmclain/magento2-successtest
app/code/Pmclain/SuccessTest/etc/frontend/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="MagentoCheckoutControllerOnepageSuccess">
<plugin name="pmclain_successtest_checkout_controller_onepage_success"
type="PmclainSuccessTestPluginSuccess"
sortOrder="10" />
</type>
</config>
app/code/Pmclain/SuccessTest/Plugin/Success.php
<?php
namespace PmclainSuccessTestPlugin;
use MagentoFrameworkEventManagerInterface;
use MagentoFrameworkViewResultPageFactory;
use MagentoFrameworkAppConfigScopeConfigInterface;
use MagentoStoreModelScopeInterface;
use MagentoCheckoutModelSession;
use MagentoSalesModelOrderFactory;
use MagentoSalesModelOrder;
class Success
/** @var ManagerInterface */
protected $_eventManager;
/** @var PageFactory */
protected $_resultPageFactory;
/** @var ScopeConfigInterface */
protected $_scopeConfig;
/** @var OrderFactory */
protected $_orderFactory;
/** @var Order */
protected $_order;
/** @var Session */
protected $_checkoutSession;
/**
* Success constructor.
* @param ManagerInterface $eventManager
* @param PageFactory $resultPageFactory
* @param ScopeConfigInterface $scopeConfig
* @param OrderFactory $orderFactory
* @param Session $session
*/
public function __construct(
ManagerInterface $eventManager,
PageFactory $resultPageFactory,
ScopeConfigInterface $scopeConfig,
OrderFactory $orderFactory,
Session $session
)
$this->_eventManager = $eventManager;
$this->_resultPageFactory = $resultPageFactory;
$this->_scopeConfig = $scopeConfig;
$this->_orderFactory = $orderFactory;
$this->_checkoutSession = $session;
/**
* @param MagentoCheckoutControllerOnepageSuccess $subject
* @param $result
* @return MagentoFrameworkViewResultPage
*/
public function afterExecute(MagentoCheckoutControllerOnepageSuccess $subject, $result)
if (!$this->_isEnabled())
return $result;
$order = $this->_getTestOrder($subject->getRequest()->getParam('order'));
if (!$order->getId())
return $result;
$this->_checkoutSession->setLastRealOrderId($order->getIncrementId());
$resultPage = $this->_resultPageFactory->create();
$this->_eventManager->dispatch(
'checkout_onepage_controller_success_action',
['order_ids' => [$order->getId()]]
);
return $resultPage;
/**
* @return bool
*/
protected function _isEnabled()
if ($this->_scopeConfig->getValue('dev/debug/success_test', ScopeInterface::SCOPE_STORE))
return true;
return false;
/**
* @param $incrementId string
app/code/Pmclain/SuccessTest/etc/adminhtml/system.xml
Below adds admin panel options to enable/disable the interceptor.
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
<section id="dev">
<group id="debug">
<field id="success_test" translate="label" type="select" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Enable Checkout Success Page Testing</label>
<source_model>MagentoConfigModelConfigSourceYesno</source_model>
</field>
</group>
</section>
</system>
</config>
app/code/Pmclain/SuccessTest/etc/config.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
<default>
<dev>
<debug>
<success_test>0</success_test>
</debug>
</dev>
</default>
</config>
app/code/Pmclain/SuccessTest/etc/module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Pmclain_SuccessTest" setup_version="0.0.1">
<sequence>
<module name="Magento_Backend" />
<module name="Magento_Checkout" />
</sequence>
</module>
</config>
app/code/Pmclain/SuccessTest/resgistration.php
<?php
MagentoFrameworkComponentComponentRegistrar::register(
MagentoFrameworkComponentComponentRegistrar::MODULE,
'Pmclain_SuccessTest',
__DIR__
);
add a comment |
Magento 2
As another answer notes, you can comment out the redirect in MagentoCheckoutControllerOnepageSuccess::execute
and force the checkout success page to load. But when the block, MagentoCheckoutBlockOnepageSuccess
, loads no order data will be present because MagentoCheckoutModelSession::getLastRealOrder
won't return an order. A better options would be an after interceptor on the controller class's execute method, where you can set a value for lastRealOrderId
in the checkout session.
This approach also provides an opportunity to dispatch the checkout_onepage_controller_success_action
event with your desired order. The event will trigger the observers MagentoGoogleAdwordsObserverSetConversionValueObserver
and MagentoGoogleAnalyticsObserverSetGoogleAnalyticsOnOrderSuccessPageViewObserver
with your test data.
The following is a fairly basic module creating the interceptor described above and allows setting the order by appending an order
query parameter with the desired increment id to the success page url. It currently won't work the the multishipping success route. It can be downloaded on github: https://github.com/pmclain/magento2-successtest
app/code/Pmclain/SuccessTest/etc/frontend/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="MagentoCheckoutControllerOnepageSuccess">
<plugin name="pmclain_successtest_checkout_controller_onepage_success"
type="PmclainSuccessTestPluginSuccess"
sortOrder="10" />
</type>
</config>
app/code/Pmclain/SuccessTest/Plugin/Success.php
<?php
namespace PmclainSuccessTestPlugin;
use MagentoFrameworkEventManagerInterface;
use MagentoFrameworkViewResultPageFactory;
use MagentoFrameworkAppConfigScopeConfigInterface;
use MagentoStoreModelScopeInterface;
use MagentoCheckoutModelSession;
use MagentoSalesModelOrderFactory;
use MagentoSalesModelOrder;
class Success
/** @var ManagerInterface */
protected $_eventManager;
/** @var PageFactory */
protected $_resultPageFactory;
/** @var ScopeConfigInterface */
protected $_scopeConfig;
/** @var OrderFactory */
protected $_orderFactory;
/** @var Order */
protected $_order;
/** @var Session */
protected $_checkoutSession;
/**
* Success constructor.
* @param ManagerInterface $eventManager
* @param PageFactory $resultPageFactory
* @param ScopeConfigInterface $scopeConfig
* @param OrderFactory $orderFactory
* @param Session $session
*/
public function __construct(
ManagerInterface $eventManager,
PageFactory $resultPageFactory,
ScopeConfigInterface $scopeConfig,
OrderFactory $orderFactory,
Session $session
)
$this->_eventManager = $eventManager;
$this->_resultPageFactory = $resultPageFactory;
$this->_scopeConfig = $scopeConfig;
$this->_orderFactory = $orderFactory;
$this->_checkoutSession = $session;
/**
* @param MagentoCheckoutControllerOnepageSuccess $subject
* @param $result
* @return MagentoFrameworkViewResultPage
*/
public function afterExecute(MagentoCheckoutControllerOnepageSuccess $subject, $result)
if (!$this->_isEnabled())
return $result;
$order = $this->_getTestOrder($subject->getRequest()->getParam('order'));
if (!$order->getId())
return $result;
$this->_checkoutSession->setLastRealOrderId($order->getIncrementId());
$resultPage = $this->_resultPageFactory->create();
$this->_eventManager->dispatch(
'checkout_onepage_controller_success_action',
['order_ids' => [$order->getId()]]
);
return $resultPage;
/**
* @return bool
*/
protected function _isEnabled()
if ($this->_scopeConfig->getValue('dev/debug/success_test', ScopeInterface::SCOPE_STORE))
return true;
return false;
/**
* @param $incrementId string
app/code/Pmclain/SuccessTest/etc/adminhtml/system.xml
Below adds admin panel options to enable/disable the interceptor.
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
<section id="dev">
<group id="debug">
<field id="success_test" translate="label" type="select" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Enable Checkout Success Page Testing</label>
<source_model>MagentoConfigModelConfigSourceYesno</source_model>
</field>
</group>
</section>
</system>
</config>
app/code/Pmclain/SuccessTest/etc/config.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
<default>
<dev>
<debug>
<success_test>0</success_test>
</debug>
</dev>
</default>
</config>
app/code/Pmclain/SuccessTest/etc/module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Pmclain_SuccessTest" setup_version="0.0.1">
<sequence>
<module name="Magento_Backend" />
<module name="Magento_Checkout" />
</sequence>
</module>
</config>
app/code/Pmclain/SuccessTest/resgistration.php
<?php
MagentoFrameworkComponentComponentRegistrar::register(
MagentoFrameworkComponentComponentRegistrar::MODULE,
'Pmclain_SuccessTest',
__DIR__
);
add a comment |
Magento 2
As another answer notes, you can comment out the redirect in MagentoCheckoutControllerOnepageSuccess::execute
and force the checkout success page to load. But when the block, MagentoCheckoutBlockOnepageSuccess
, loads no order data will be present because MagentoCheckoutModelSession::getLastRealOrder
won't return an order. A better options would be an after interceptor on the controller class's execute method, where you can set a value for lastRealOrderId
in the checkout session.
This approach also provides an opportunity to dispatch the checkout_onepage_controller_success_action
event with your desired order. The event will trigger the observers MagentoGoogleAdwordsObserverSetConversionValueObserver
and MagentoGoogleAnalyticsObserverSetGoogleAnalyticsOnOrderSuccessPageViewObserver
with your test data.
The following is a fairly basic module creating the interceptor described above and allows setting the order by appending an order
query parameter with the desired increment id to the success page url. It currently won't work the the multishipping success route. It can be downloaded on github: https://github.com/pmclain/magento2-successtest
app/code/Pmclain/SuccessTest/etc/frontend/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="MagentoCheckoutControllerOnepageSuccess">
<plugin name="pmclain_successtest_checkout_controller_onepage_success"
type="PmclainSuccessTestPluginSuccess"
sortOrder="10" />
</type>
</config>
app/code/Pmclain/SuccessTest/Plugin/Success.php
<?php
namespace PmclainSuccessTestPlugin;
use MagentoFrameworkEventManagerInterface;
use MagentoFrameworkViewResultPageFactory;
use MagentoFrameworkAppConfigScopeConfigInterface;
use MagentoStoreModelScopeInterface;
use MagentoCheckoutModelSession;
use MagentoSalesModelOrderFactory;
use MagentoSalesModelOrder;
class Success
/** @var ManagerInterface */
protected $_eventManager;
/** @var PageFactory */
protected $_resultPageFactory;
/** @var ScopeConfigInterface */
protected $_scopeConfig;
/** @var OrderFactory */
protected $_orderFactory;
/** @var Order */
protected $_order;
/** @var Session */
protected $_checkoutSession;
/**
* Success constructor.
* @param ManagerInterface $eventManager
* @param PageFactory $resultPageFactory
* @param ScopeConfigInterface $scopeConfig
* @param OrderFactory $orderFactory
* @param Session $session
*/
public function __construct(
ManagerInterface $eventManager,
PageFactory $resultPageFactory,
ScopeConfigInterface $scopeConfig,
OrderFactory $orderFactory,
Session $session
)
$this->_eventManager = $eventManager;
$this->_resultPageFactory = $resultPageFactory;
$this->_scopeConfig = $scopeConfig;
$this->_orderFactory = $orderFactory;
$this->_checkoutSession = $session;
/**
* @param MagentoCheckoutControllerOnepageSuccess $subject
* @param $result
* @return MagentoFrameworkViewResultPage
*/
public function afterExecute(MagentoCheckoutControllerOnepageSuccess $subject, $result)
if (!$this->_isEnabled())
return $result;
$order = $this->_getTestOrder($subject->getRequest()->getParam('order'));
if (!$order->getId())
return $result;
$this->_checkoutSession->setLastRealOrderId($order->getIncrementId());
$resultPage = $this->_resultPageFactory->create();
$this->_eventManager->dispatch(
'checkout_onepage_controller_success_action',
['order_ids' => [$order->getId()]]
);
return $resultPage;
/**
* @return bool
*/
protected function _isEnabled()
if ($this->_scopeConfig->getValue('dev/debug/success_test', ScopeInterface::SCOPE_STORE))
return true;
return false;
/**
* @param $incrementId string
app/code/Pmclain/SuccessTest/etc/adminhtml/system.xml
Below adds admin panel options to enable/disable the interceptor.
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
<section id="dev">
<group id="debug">
<field id="success_test" translate="label" type="select" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Enable Checkout Success Page Testing</label>
<source_model>MagentoConfigModelConfigSourceYesno</source_model>
</field>
</group>
</section>
</system>
</config>
app/code/Pmclain/SuccessTest/etc/config.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
<default>
<dev>
<debug>
<success_test>0</success_test>
</debug>
</dev>
</default>
</config>
app/code/Pmclain/SuccessTest/etc/module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Pmclain_SuccessTest" setup_version="0.0.1">
<sequence>
<module name="Magento_Backend" />
<module name="Magento_Checkout" />
</sequence>
</module>
</config>
app/code/Pmclain/SuccessTest/resgistration.php
<?php
MagentoFrameworkComponentComponentRegistrar::register(
MagentoFrameworkComponentComponentRegistrar::MODULE,
'Pmclain_SuccessTest',
__DIR__
);
Magento 2
As another answer notes, you can comment out the redirect in MagentoCheckoutControllerOnepageSuccess::execute
and force the checkout success page to load. But when the block, MagentoCheckoutBlockOnepageSuccess
, loads no order data will be present because MagentoCheckoutModelSession::getLastRealOrder
won't return an order. A better options would be an after interceptor on the controller class's execute method, where you can set a value for lastRealOrderId
in the checkout session.
This approach also provides an opportunity to dispatch the checkout_onepage_controller_success_action
event with your desired order. The event will trigger the observers MagentoGoogleAdwordsObserverSetConversionValueObserver
and MagentoGoogleAnalyticsObserverSetGoogleAnalyticsOnOrderSuccessPageViewObserver
with your test data.
The following is a fairly basic module creating the interceptor described above and allows setting the order by appending an order
query parameter with the desired increment id to the success page url. It currently won't work the the multishipping success route. It can be downloaded on github: https://github.com/pmclain/magento2-successtest
app/code/Pmclain/SuccessTest/etc/frontend/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="MagentoCheckoutControllerOnepageSuccess">
<plugin name="pmclain_successtest_checkout_controller_onepage_success"
type="PmclainSuccessTestPluginSuccess"
sortOrder="10" />
</type>
</config>
app/code/Pmclain/SuccessTest/Plugin/Success.php
<?php
namespace PmclainSuccessTestPlugin;
use MagentoFrameworkEventManagerInterface;
use MagentoFrameworkViewResultPageFactory;
use MagentoFrameworkAppConfigScopeConfigInterface;
use MagentoStoreModelScopeInterface;
use MagentoCheckoutModelSession;
use MagentoSalesModelOrderFactory;
use MagentoSalesModelOrder;
class Success
/** @var ManagerInterface */
protected $_eventManager;
/** @var PageFactory */
protected $_resultPageFactory;
/** @var ScopeConfigInterface */
protected $_scopeConfig;
/** @var OrderFactory */
protected $_orderFactory;
/** @var Order */
protected $_order;
/** @var Session */
protected $_checkoutSession;
/**
* Success constructor.
* @param ManagerInterface $eventManager
* @param PageFactory $resultPageFactory
* @param ScopeConfigInterface $scopeConfig
* @param OrderFactory $orderFactory
* @param Session $session
*/
public function __construct(
ManagerInterface $eventManager,
PageFactory $resultPageFactory,
ScopeConfigInterface $scopeConfig,
OrderFactory $orderFactory,
Session $session
)
$this->_eventManager = $eventManager;
$this->_resultPageFactory = $resultPageFactory;
$this->_scopeConfig = $scopeConfig;
$this->_orderFactory = $orderFactory;
$this->_checkoutSession = $session;
/**
* @param MagentoCheckoutControllerOnepageSuccess $subject
* @param $result
* @return MagentoFrameworkViewResultPage
*/
public function afterExecute(MagentoCheckoutControllerOnepageSuccess $subject, $result)
if (!$this->_isEnabled())
return $result;
$order = $this->_getTestOrder($subject->getRequest()->getParam('order'));
if (!$order->getId())
return $result;
$this->_checkoutSession->setLastRealOrderId($order->getIncrementId());
$resultPage = $this->_resultPageFactory->create();
$this->_eventManager->dispatch(
'checkout_onepage_controller_success_action',
['order_ids' => [$order->getId()]]
);
return $resultPage;
/**
* @return bool
*/
protected function _isEnabled()
if ($this->_scopeConfig->getValue('dev/debug/success_test', ScopeInterface::SCOPE_STORE))
return true;
return false;
/**
* @param $incrementId string
app/code/Pmclain/SuccessTest/etc/adminhtml/system.xml
Below adds admin panel options to enable/disable the interceptor.
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
<section id="dev">
<group id="debug">
<field id="success_test" translate="label" type="select" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Enable Checkout Success Page Testing</label>
<source_model>MagentoConfigModelConfigSourceYesno</source_model>
</field>
</group>
</section>
</system>
</config>
app/code/Pmclain/SuccessTest/etc/config.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
<default>
<dev>
<debug>
<success_test>0</success_test>
</debug>
</dev>
</default>
</config>
app/code/Pmclain/SuccessTest/etc/module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Pmclain_SuccessTest" setup_version="0.0.1">
<sequence>
<module name="Magento_Backend" />
<module name="Magento_Checkout" />
</sequence>
</module>
</config>
app/code/Pmclain/SuccessTest/resgistration.php
<?php
MagentoFrameworkComponentComponentRegistrar::register(
MagentoFrameworkComponentComponentRegistrar::MODULE,
'Pmclain_SuccessTest',
__DIR__
);
edited Aug 14 '18 at 9:19
Jacta
1074 bronze badges
1074 bronze badges
answered Aug 4 '17 at 11:14
PmclainPmclain
1,64810 silver badges17 bronze badges
1,64810 silver badges17 bronze badges
add a comment |
add a comment |
protected by Community♦ Nov 4 '15 at 8:15
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
2
This question created varied answers which are all full of "win". Anyone visiting here should peruse all the answers.
– Chris K
Nov 13 '14 at 21:05