Post by trujve » Sun Dec 03, 2023 7:15 am

Hej folks,

I am currently developing my first OC4 extension and a questions have arisen that I am hoping you can help me with.

On the thank you page (success.twig) I need the "order_id" after purchase, because I need some order data there. My idea was the following:

Code: Select all

if (isset($this->session->data['order_id'])) {
$this->load->model('checkout/order');
$data['orderDetails'] = $this->model_checkout_order->getOrder($this->session->data['order_id']);
}
I thought I could get the "order_id" and other data this way, however I quickly realized that this session will be deleted on the success page. So no chance.

Do you have a idea for me on how to get this data on the success page?

Best
Jack

New member

Posts

Joined
Tue Jul 09, 2019 7:25 pm

Post by trujve » Sun Dec 03, 2023 8:23 pm

What I did so far is that I inserted with "before" handler this code:

Code: Select all

if (isset($this->session->data['guest'])) { 
$data['get_email_data'] = $this->session->data['guest']['email']; 
} elseif($this->customer->isLogged()) {
$data['get_email_data'] = $this->customer->getEmail();
}
$data['get_orderid_data'] = $this->session->data['order_id'];
between:

Code: Select all

if (isset($this->session->data['order_id'])) {
and:

Code: Select all

$this->cart->clear();
in /catalog/controller/checkout/success.php

Then I added:

Code: Select all

ID: {{ get_orderid_data }}
E-Mail: {{ get_email_data }}
In /catalog/view/.../common/success.twig

The result is poor, the variables are not in the data array on the success page. Can you imagine why?

Best,
Jack

New member

Posts

Joined
Tue Jul 09, 2019 7:25 pm
Who is online

Users browsing this forum: No registered users and 3 guests