Post by brandblusser » Sat Dec 02, 2017 6:31 pm

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!

New member

Posts

Joined
Thu Nov 09, 2017 8:22 pm

Post by straightlight » Sat Dec 02, 2017 11:01 pm

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.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by brandblusser » Sat Dec 02, 2017 11:36 pm

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?

New member

Posts

Joined
Thu Nov 09, 2017 8:22 pm

Post by straightlight » Sat Dec 02, 2017 11:40 pm

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.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by brandblusser » Sun Dec 03, 2017 12:33 am

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'] = '';

			}

New member

Posts

Joined
Thu Nov 09, 2017 8:22 pm

Post by straightlight » Sun Dec 03, 2017 12:41 am

As mentioned above, ensure to modify the invoice() method. The lines you provided for the customer group array is within the info() method.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by brandblusser » Sun Dec 03, 2017 12:57 am

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

New member

Posts

Joined
Thu Nov 09, 2017 8:22 pm

Post by straightlight » Sun Dec 03, 2017 1:00 am

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.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by brandblusser » Sun Dec 03, 2017 1:30 am

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.

New member

Posts

Joined
Thu Nov 09, 2017 8:22 pm

Post by straightlight » Sun Dec 03, 2017 1:36 am

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.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by brandblusser » Sun Dec 03, 2017 1:37 am

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.

New member

Posts

Joined
Thu Nov 09, 2017 8:22 pm

Post by straightlight » Sun Dec 03, 2017 1:44 am

What about the previous step on my post above for defining those variables, did you added them as well?

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by brandblusser » Sun Dec 03, 2017 1:50 am

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

				}


New member

Posts

Joined
Thu Nov 09, 2017 8:22 pm

Post by straightlight » Sun Dec 03, 2017 1:55 am

Please send the attachment. I'll take a look at it.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by brandblusser » Sun Dec 03, 2017 2:08 am

Thanks!
Sent by PM

New member

Posts

Joined
Thu Nov 09, 2017 8:22 pm

Post by brandblusser » Mon Dec 04, 2017 4:52 am

Solved! Got it all working now. Thanks again straightlight!

New member

Posts

Joined
Thu Nov 09, 2017 8:22 pm

Post by dibea » Wed Mar 21, 2018 8:19 pm

brandblusser ,

can you please share how did make it work?

Newbie

Posts

Joined
Wed Mar 21, 2018 8:15 pm

Post by skt » Wed May 16, 2018 1:56 am

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.

skt
Newbie

Posts

Joined
Wed Jul 22, 2015 1:37 am

Post by dkkmaju » Sun Sep 30, 2018 4:23 pm

Thank you, it work.. for image i just put like that "'../image/'

Newbie

Posts

Joined
Sun Sep 09, 2018 9:49 pm

Post by falger » Fri Nov 16, 2018 3:38 pm

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

Newbie

Posts

Joined
Fri Nov 16, 2018 3:29 pm
Who is online

Users browsing this forum: dev15 and 44 guests