Page 1 of 2

Logo on invoice version 3.0.2.0

Posted: Sat Dec 02, 2017 6:31 pm
by brandblusser
I tried to add the shop logo to the invoice (the one I can print and send with the order) but somehow it doesn't work. Must be my mistake but I can't figure out what I'm doing wrong.
This is what I did:
1. I took the file: admin/view/template/sale/order_invoice.twig and tried to change

Code: Select all

<div class="container">
  {% for order in orders %}
  <div style="page-break-after: always;">
    <h1>{{ text_invoice }} #{{ order.order_id }}</h1>
into:

Code: Select all

<div class="container">
  {% for order in orders %}
  <div style="page-break-after: always;">
  <img src="mysite.nl/image/catalog/myimage.jpg" alt="" />
    <h1>{{ text_invoice }} #{{ order.order_id }}</h1>
But it doesn't show on the invoice and I can't see the new line on the source code of the generated page. I did clear the cache.

Should I edit another file? Can anyone put me in the right direction? Thanks in advance!

Re: Logo on invoice version 3.0.2.0

Posted: Sat Dec 02, 2017 11:01 pm
by straightlight
In admin/controller/sale/order.php file, in the invoice() method,

find:

Code: Select all

$store_fax = $store_info['config_fax'];
		
add below:

Code: Select all

$store_name = $store_info['config_name'];
					
					if (is_file(DIR_IMAGE . $store_info['config_logo'])) {
						$store_logo = $data['base'] . 'image/' . $store_info['config_logo'];
					} else {
						$store_logo = '';
					}
Then, right below, find:

Code: Select all

$store_fax = $this->config->get('config_fax');
add below:

Code: Select all

$store_name = $this->config->get('config_name');
					
					if (is_file(DIR_IMAGE . $this->config->get('config_logo'))) {
						$store_logo = $data['base'] . 'image/' . $this->config->get('config_logo');
					} else {
						$store_logo = '';
					}
Then, find:

Code: Select all

'store_fax'        => $store_fax,
add below:

Code: Select all

'order_store_name' => $store_name,
'order_store_logo' => $store_logo,
Ensure each of your store logos are indeed stored in your root image folder. Not image/catalog folder in this case.

Then, in your order_invoice.twig file,

find:

Code: Select all

<td style="width: 50%;"><address>
add below:

Code: Select all

<img src="{{ order.order_store_logo }}" title="{{ order.order_store_name }}" alt="{{ order.order_store_name }}" class="img-responsive" />
This should rectify the issue.

Re: Logo on invoice version 3.0.2.0

Posted: Sat Dec 02, 2017 11:36 pm
by brandblusser
Thanks a lot straightlight! I'll give it a try and let you know if it works.
Should I rename the image file to "config_logo" . So, config_logo.jpg?

Re: Logo on invoice version 3.0.2.0

Posted: Sat Dec 02, 2017 11:40 pm
by straightlight
No. The config_logo is the configuration key to get the actual logo filename when especially using multi-stores. However, the logo filename must match the exact filename that you selected for your logo store.

Re: Logo on invoice version 3.0.2.0

Posted: Sun Dec 03, 2017 12:33 am
by brandblusser
No luck yet. I get an error message:

Code: Select all

2017-12-02 16:03:40 - PHP Notice:  Undefined variable: store_name in /home/mysite/public_html/admin/controller/sale/order.php on line 1656
2017-12-02 16:03:40 - PHP Notice:  Undefined variable: store_logo in /home/mysite/public_html/admin/controller/sale/order.php on line 1656
Line 1656 is an empty line in the script right below this:

Code: Select all

			$customer_group_info = $this->model_customer_customer_group->getCustomerGroup($order_info['customer_group_id']);



			if ($customer_group_info) {

				$data['customer_group'] = $customer_group_info['name'];

			} else {

				$data['customer_group'] = '';

			}

Re: Logo on invoice version 3.0.2.0

Posted: Sun Dec 03, 2017 12:41 am
by straightlight
As mentioned above, ensure to modify the invoice() method. The lines you provided for the customer group array is within the info() method.

Re: Logo on invoice version 3.0.2.0

Posted: Sun Dec 03, 2017 12:57 am
by brandblusser
I did make all the changes in the public function invoice()
Checked it just to be sure.
But the error message says that the undefined variables are on line 1656 of the order.php script which is an empty line within the info() function. I didn't change anything in that function

Re: Logo on invoice version 3.0.2.0

Posted: Sun Dec 03, 2017 1:00 am
by straightlight
This line:

Code: Select all

$customer_group_info = $this->model_customer_customer_group->getCustomerGroup($order_info['customer_group_id']);
does not exist in the core of Opencart within the invoice() method. If you do see this line inclusively, it is generated by an installed extension or you are not using the latest version of Opencart.

Re: Logo on invoice version 3.0.2.0

Posted: Sun Dec 03, 2017 1:30 am
by brandblusser
That's right. That line is in the info() method. It is not in my invoice() method.

But, the error message I get:

Code: Select all

2017-12-02 17:16:11 - PHP Notice:  Undefined variable: store_name in /home/mysite/public_html/admin/controller/sale/order.php on line 1656
2017-12-02 17:16:11 - PHP Notice:  Undefined variable: store_logo in /home/mysite/public_html/admin/controller/sale/order.php on line 1656
says that the missing variable is on line 1656, which is inside the info() method.

So, I made all the changes to the invoice() method and the error message says there's a missing variable inside the info() method.

Re: Logo on invoice version 3.0.2.0

Posted: Sun Dec 03, 2017 1:36 am
by straightlight
So, I made all the changes to the invoice() method and the error message says there's a missing variable inside the info() method.
Please post your order.php file as an attachment. Do NOT post the entire file with the code blocks for this file.

Re: Logo on invoice version 3.0.2.0

Posted: Sun Dec 03, 2017 1:37 am
by brandblusser
I downloaded the order.php from the server. It was installed through CPanel.
I took the order.php from a fresh downloaded archive and seems that line 1656 should be in this array:

Code: Select all

				$data['orders'][] = array(
					'order_id'	       => $order_id,
					'invoice_no'       => $invoice_no,
					'date_added'       => date($this->language->get('date_format_short'), strtotime($order_info['date_added'])),
					'store_name'       => $order_info['store_name'],
					'store_url'        => rtrim($order_info['store_url'], '/'),
					'store_address'    => nl2br($store_address),
					'store_email'      => $store_email,
					'store_telephone'  => $store_telephone,
					'store_fax'        => $store_fax,
					'order_store_name' => $store_name,
					'order_store_logo' => $store_logo,
					'email'            => $order_info['email'],
					'telephone'        => $order_info['telephone'],
					'shipping_address' => $shipping_address,
					'shipping_method'  => $order_info['shipping_method'],
					'payment_address'  => $payment_address,
					'payment_method'   => $order_info['payment_method'],
					'product'          => $product_data,
					'voucher'          => $voucher_data,
					'total'            => $total_data,
					'comment'          => nl2br($order_info['comment'])
				);
So, the error message refers to a missing variable in this array.

Re: Logo on invoice version 3.0.2.0

Posted: Sun Dec 03, 2017 1:44 am
by straightlight
What about the previous step on my post above for defining those variables, did you added them as well?

Re: Logo on invoice version 3.0.2.0

Posted: Sun Dec 03, 2017 1:50 am
by brandblusser
Yes, I did:

Code: Select all

				if ($store_info) {

					$store_address = $store_info['config_address'];

					$store_email = $store_info['config_email'];

					$store_telephone = $store_info['config_telephone'];

					$store_fax = $store_info['config_fax'];
					
					//aanvulling voor logo in factuur
					$store_name = $store_info['config_name'];
					
					if (is_file(DIR_IMAGE . $store_info['config_logo'])) {
						$store_logo = $data['base'] . 'image/' . $store_info['config_logo'];
					} else {
						$store_logo = '';
					}
					//einde aanvulling

				} else {

					$store_address = $this->config->get('config_address');

					$store_email = $this->config->get('config_email');

					$store_telephone = $this->config->get('config_telephone');

					$store_fax = $this->config->get('config_fax');
					
					//aanvulling voor logo in factuur
					$store_name = $this->config->get('config_name');
					
					if (is_file(DIR_IMAGE . $this->config->get('config_logo'))) {
						$store_logo = $data['base'] . 'image/' . $this->config->get('config_logo');
					} else {
						$store_logo = '';
					}
					//einde aanvulling

				}


Re: Logo on invoice version 3.0.2.0

Posted: Sun Dec 03, 2017 1:55 am
by straightlight
Please send the attachment. I'll take a look at it.

Re: Logo on invoice version 3.0.2.0

Posted: Sun Dec 03, 2017 2:08 am
by brandblusser
Thanks!
Sent by PM

Re: Logo on invoice version 3.0.2.0

Posted: Mon Dec 04, 2017 4:52 am
by brandblusser
Solved! Got it all working now. Thanks again straightlight!

Re: Logo on invoice version 3.0.2.0

Posted: Wed Mar 21, 2018 8:19 pm
by dibea
brandblusser ,

can you please share how did make it work?

Re: Logo on invoice version 3.0.2.0

Posted: Wed May 16, 2018 1:56 am
by skt
i also want to install the store logo to my INVOICE. kindly explain with out any error. Opencast version is Version 3.0.2.0.
Please help me.

Re: Logo on invoice version 3.0.2.0

Posted: Sun Sep 30, 2018 4:23 pm
by dkkmaju
Thank you, it work.. for image i just put like that "'../image/'

Re: Logo on invoice version 3.0.2.0

Posted: Fri Nov 16, 2018 3:38 pm
by falger
Hi there
I did not got it to work with this instructions. Also the ../image/ part did not help.
I do have OC 3.0.2.0 with the german language.
I am thankful for any help.
- falger