Page 1 of 1
Order number and Customer Mail on success page
Posted: Tue Jul 23, 2019 6:28 am
by MeckerOpa
Hello,
I need the order number and customer mail on the success page. My rating system provides me an code snippet, that needs this informations.
Code: Select all
<div id="srt-customer-data" style="display:none;">
<span id="srt-customer-email">CUSTOMERMAIL</span>
<span id="srt-customer-reference">ORDERNUMBER</span>
</div>
My customers don't need to register, to take any orders. I searched the board for some informations, because I just need to query the database for this informations. But I didn't find anything which fits my needs and I'm not able to code this by myself.
My opencart version is the 2.0.3.1
cheers,
Chris
Re: Order number and Customer Mail on success page
Posted: Tue Jul 23, 2019 7:35 am
by IP_CAM
I would try this one, it prints out a complete Invoice.
Checkout Success Order Info
This is a vqmod that will add the order details (same as invoice / order history) to the checkout success page.
It also adds a print button.
https://www.opencart.com/index.php?rout ... n_id=21541
---

---
or this one:
Order info on Confirm / Order Success Page with print button
Module helps to show order information on order confirm page with "print invoice" button.
Features -
show order info on order success page
show payment/shipping info on confirm order step of checkout
print button to print invoice on order success page
https://www.opencart.com/index.php?rout ... n_id=36046
---

---
Ernie
Re: Order number and Customer Mail on success page
Posted: Tue Jul 23, 2019 4:31 pm
by MeckerOpa
Hi,
I already saw it in the marketplace. But I'm not sure, how I can combine the code from the rating system. I will take a closer look on that.
Thanks
Re: Order number and Customer Mail on success page
Posted: Tue Jul 23, 2019 4:45 pm
by MeckerOpa
IP_CAM wrote: ↑Tue Jul 23, 2019 7:35 am
I would try this one, it prints out a complete Invoice.
Checkout Success Order Info
This is a vqmod that will add the order details (same as invoice / order history) to the checkout success page.
It also adds a print button.
https://www.opencart.com/index.php?rout ... n_id=21541
---

---
or this one:
Order info on Confirm / Order Success Page with print button
Module helps to show order information on order confirm page with "print invoice" button.
Features -
show order info on order success page
show payment/shipping info on confirm order step of checkout
print button to print invoice on order success page
https://www.opencart.com/index.php?rout ... n_id=36046
---

---
Ernie
On both extensions the mail adress isn't provided. I don't know how to get this information by myself. Can anyone help me to get this done?
Re: Order number and Customer Mail on success page
Posted: Tue Jul 23, 2019 5:15 pm
by OSWorX
Simply fetch the data inside the controller, assign to a new value (array) and call them inside the template.
If you have only guest orders, the email address is inside the session data 'guest', the order_id is also present in the session data 'order_id'.
If you have also orders from registered users, the procedure will be a bit different.
Re: Order number and Customer Mail on success page
Posted: Tue Jul 23, 2019 5:42 pm
by MeckerOpa
Okay, I understand that:
Code: Select all
$order_id = $this->session->data['order_id']
is the request for the order number. So $order_id store the order number.
But I don't know what is the right syntax for the e-mail address. I also understand, that the guest mail is stored in the session, but the registered user adress isn't.
Where can I find the variable names like "data['order_id']", or is it just the table in the database? I need a push, because i'm tied up.

Re: Order number and Customer Mail on success page
Posted: Tue Jul 23, 2019 7:23 pm
by OSWorX
You need:
1. order_id >
$this->session->data['order_id']
2. Email Guest >
$this->session->data['guest']['email']
If the user has made the order as registered, you have to call
$this->Customer->getEmail() to get the Email Address
Now you have all 2, assign them to $data['email'] and $data['order_id'] and you will have what you need inside your template.
Or simplier: assign the while output in a variable, like:
Code: Select all
$data['tracker'] = '<div id="srt-customer-data" style="display:none;">
<span id="srt-customer-email">CUSTOMERMAIL</span>
<span id="srt-customer-reference">ORDERNUMBER</span>
</div>';
and add only this single variable to your template:
Re: Order number and Customer Mail on success page
Posted: Tue Jul 23, 2019 8:35 pm
by MeckerOpa
Thank you very much. This should help me!
But your simpler solution, won't work for me. The "ORDERNUMBER" in the span, is just a placeholder for the variable. There have to be the Number.
But I think I understand now. I will give you feedback

Re: Order number and Customer Mail on success page
Posted: Tue Jul 23, 2019 10:11 pm
by OSWorX
MeckerOpa wrote: ↑Tue Jul 23, 2019 8:35 pm
Thank you very much. This should help me!
But your simpler solution, won't work for me. The "ORDERNUMBER" in the span, is just a placeholder for the variable. There have to be the Number.
But I think I understand now. I will give you feedback
For example:
Code: Select all
<span id="srt-customer-reference">' . $this->session->data['order_id'] . '</span>
Re: Order number and Customer Mail on success page
Posted: Tue Jul 30, 2019 6:08 am
by MeckerOpa
Short information: I did it by inserting this code:
Code: Select all
if (isset($this->session->data['guest'])) {
$data['needemail'] = $this->session->data['guest']['email']; // Guest user's email
} elseif($this->customer->isLogged()) {
$data['needemail'] = $this->customer->getEmail(); // Customer's email
}
$data['needorderid'] = $this->session->data['order_id'];
between:
Code: Select all
if (isset($this->session->data['order_id'])) {
and:
in /catalog/controller/checkout/success.php
Then I added:
Code: Select all
<!-- BEGIN - EasyReviews Addon | www.shopvote.de -->
<div id="srt-customer-data" style="display:none;">
<span id="srt-customer-email">{{ needemail }}</span>
<span id="srt-customer-reference">{{ needorderid }}</span>
</div>
<!-- END - EasyReviews Addon | www.shopvote.de -->
In /catalog/view/theme/*/template/common/success.twig
And now everything is working fine. If someone wants to create a modification for ShopVote, feel free to use this.
Thanks for all the help. I had to learn many things in understanding the structure of opencart (controller, model, view...).
Cheers,
Chris