Post by MeckerOpa » Tue Jul 23, 2019 6:28 am

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

Newbie

Posts

Joined
Sat Jun 27, 2015 12:21 am

Post by IP_CAM » 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
---
Image
---
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
---
Image
---
Ernie

My Github OC Site: https://github.com/IP-CAM
5'200 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by MeckerOpa » Tue Jul 23, 2019 4:31 pm

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

Newbie

Posts

Joined
Sat Jun 27, 2015 12:21 am

Post by MeckerOpa » Tue Jul 23, 2019 4:45 pm

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
---
Image
---
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
---
Image
---
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?

Newbie

Posts

Joined
Sat Jun 27, 2015 12:21 am

Post by OSWorX » Tue Jul 23, 2019 5:15 pm

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.

Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.


User avatar
Guru Member

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by MeckerOpa » Tue Jul 23, 2019 5:42 pm

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. :crazy:

Newbie

Posts

Joined
Sat Jun 27, 2015 12:21 am

Post by OSWorX » Tue Jul 23, 2019 7:23 pm

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:

Code: Select all

<?php echo $tracker; ?>

Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.


User avatar
Guru Member

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by MeckerOpa » 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 :)

Newbie

Posts

Joined
Sat Jun 27, 2015 12:21 am

Post by OSWorX » Tue Jul 23, 2019 10:11 pm

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>

Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.


User avatar
Guru Member

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by MeckerOpa » Tue Jul 30, 2019 6:08 am

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:

Code: Select all

$this->cart->clear();
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

Newbie

Posts

Joined
Sat Jun 27, 2015 12:21 am
Who is online

Users browsing this forum: No registered users and 167 guests