At the end of the checkout process, I have a number of tasks to complete to fulfill the banks requirements, and to do this i need to pass $this->session->data to a new page (controller). However, I've noticed the construct(s) that manage controllers understandably resets session data arrays and the like. Does anyone have a good solution for me to keep the entire $this->session->data array (or somthing similar) for use on another page?
Thanks.
Opencart 3.0.3.1
Default Theme
Single Store
Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com
But unfortuantely given the stateless nature of PHP this will not work, a straight copy of the array will not be available for other pages.
I've tried using native $_SESSION, but it seems OC unsets this as well.
I was wondering if OC uses any specific named arrays that do not unset when a new page is called, for the specific purpose of passing data between pages?
Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com
I've just tested the suggested solution but unfortunately the something in OC appears to unset $this->session->data at this level, meaning all and any array associated with $this->session->data is unset.
For example..
in ControllerCheckoutPaymentMethod i can define
$this->session->data['checkoutData']=array('customer_id=>$this->session->data['customer_id']);
immdeiately before
$this->response->setOutput($this->load->view('checkout/payment_method', $data));
But once payment_method.twig is processed and a form post response calls
class ControllerCheckoutBankProcessing extends Controller {
public function index() {
print_r($this->session->data['checkoutData']);
I get the error "Notice: Undefined index: checkoutData in /mydomain/catalog/controller/checkout/bank_processing.php on line 4"
However if I print_r($this->session->data) a new session array has been constructed (i assume by the controller), not including ['checkoutData'] .
Should work. I have just checked this part of code. Just change line in red to:68Thorby68 wrote: ↑Wed Feb 19, 2020 8:51 pmMany thanks thekrotek, I really appreciate you help.
I've just tested the suggested solution but unfortunately the something in OC appears to unset $this->session->data at this level, meaning all and any array associated with $this->session->data is unset.
For example..
in ControllerCheckoutPaymentMethod i can define
$this->session->data['checkoutData']=array('customer_id=>$this->session->data['customer_id']);
immdeiately before
$this->response->setOutput($this->load->view('checkout/payment_method', $data));
But once payment_method.twig is processed and a form post response calls
class ControllerCheckoutBankProcessing extends Controller {
public function index() {
print_r($this->session->data['checkoutData']);
I get the error "Notice: Undefined index: checkoutData in /mydomain/catalog/controller/checkout/bank_processing.php on line 4"
However if I print_r($this->session->data) a new session array has been constructed (i assume by the controller), not including ['checkoutData'] .
Code: Select all
$this->session->data['checkoutData'] = array('customer_id'=>$this->session->data['customer_id']);
Custom OpenCart modules and solutions. You can write PM with additional questions... Extensions you can find here
The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.
Regards,
Straightlight
Programmer / Opencart Tester
I made the suggested changes but alas "no cigar".
On the bank process page (after setting the session data as suggested)
print_r($this->sesion-data['checkoutData']);
Notice: Undefined index: checkoutData in /mydomain/catalog/controller/checkout/bank_processing.php on line 5
print_r($this->sesion-data);
Array ( [language] => en-gb [currency] => GBP )
I'm not sure what is going on here as I cannot see where session is being unset and where new session is created. I'll have to trawl through the system folder and try and work out what is going on, especially as you have taken the time to test this yourself and seen it working.
If I find what was causing the problem in my install, and I find a fix, I will post here for others to experience.
Thank you again, I've taken ltos of your time.
To work around that, you'll either need to (1) put the variable into the URL that the payment gateway visits, so you can retrieve it from the GET request, or (2) store the value in a custom database table or column, and load it based on the order_id or some other data that is shared across the two separate sessions. Both of those require some coding knowhow, so if you're not sure how to do those things I would recommend hiring someone to assist. If you need to find a developer, you can post a request in the OpenCart "Commercial Support" forum, which is checked by a number of OpenCart developers. You can also try checking out the OpenCart "Partners" area.
The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.
Regards,
Straightlight
Programmer / Opencart Tester
Users browsing this forum: No registered users and 24 guests