Reputation: 71
I am developing an OpenCart module and struggling with getting the order_id by using $this->session->data['order_id']
.
My module is working fine if I comment out the part which unsets the order_id session variable in ControllerCheckoutSuccess
class.
How can I ensure that I get the order_id before ControllerCheckoutSuccess
unsets it?
Edit1: I need the order id to extract details like customer name, total amount, subtotal etc for that particular order. Is there some other method by which I can get the order id?
Edit2: Added this code in 'store/catalog/controller/module/myModule.php'
in index()
function. Using it to store order_id in temp session variable and use it on order success -
if (isset($this->session->data['temp_order_id'])
&& isset($this->request->get['route'])
&& $this->request->get['route'] == 'checkout/success')
{
// perform custom action
unset($this->session->data['temp_order_id']);
}
elseif (isset($this->session->data['order_id']))
{
$this->session->data['temp_order_id'] = $this->session->data['order_id'];
}
Please help!
Upvotes: 0
Views: 10676
Reputation: 71
Couldn't find any solution for this so sorted it by dynamically adding code (as mentioned by Sankar V) using vQmod. However, it adds a dependency that vQmod should be installed already.
Hope it helps someone facing similar problem.
Upvotes: 0
Reputation: 4128
In catalog/controller/checkout/success.php
file, add:
$this->session->data['temp_order_id'] = $this->session->data['order_id']
;
After:
if (isset($this->session->data['order_id'])) {
Then call your custom module or call your custom module before checkout success page controller is called.
Upvotes: 3