Post by zumbador » Tue Nov 18, 2014 6:56 am

Hi, how can i add a logo to the invoice in opencart 2.0. There is this link,

http://forum.opencart.com/viewtopic.php?f=20&t=5952

that explains how to do it for 1.5 however it does not work in 2.0. Any ideas?

Newbie

Posts

Joined
Thu Nov 04, 2010 11:14 pm
Location - kanasa

Post by fido-x » Tue Nov 18, 2014 10:55 am

In admin/controller/sale/order.php find the following code, starting at line 2369:

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'];
} 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');
}
and replace with:

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'];
	if (isset($store_info['config_logo']) && is_file(DIR_IMAGE . $store_info['config_logo'])) {
		$store_logo = $this->model_tool_image->resize($store_info['config_logo'], 100, 100);
	} else {
		$store_logo = $this->model_tool_image->resize('no_image.png', 100, 100);
	}
} 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');
	if ($this->config->get('config_logo') && is_file(DIR_IMAGE . $this->config->get('config_logo'))) {
		$store_logo = $this->model_tool_image->resize($this->config->get('config_logo'), 100, 100);
	} else {
		$store_logo = $this->model_tool_image->resize('no_image.png', 100, 100);
	}
}
Insert at what is now line 2489:

Code: Select all

'store_logo'         => $store_logo,
Then, in admin/view/template/sale/order_invoice.tpl, insert the following at line 17:

Code: Select all

<div class="pull-right"><img src="<?php echo $order['store_logo']; ?>" alt="<?php echo $order['store_name']; ?>" /></div>
This should place the store logo on the top right hand side of the invoice.

Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia

Post by zumbador » Wed Nov 19, 2014 12:12 am

Hi, Thank you for responding!! I did not find the code you referenced at line 2369. I did found the following lines of code, which one am i suppose to replace?

Lines 1957-1970

Code: Select all

if ($order_info) {
				$store_info = $this->model_setting_setting->getSetting('config', $order_info['store_id']);

				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'];
				} 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');
				}
Lines 2198-2212

Code: Select all

// Make sure there is a shipping method
			if ($order_info && $order_info['shipping_code']) {
				$store_info = $this->model_setting_setting->getSetting('config', $order_info['store_id']);

				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'];
				} 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');
				}
There is no line No. 2489. below are lines 2302-2317

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,
					'email'              => $order_info['email'],
					'telephone'          => $order_info['telephone'],
					'shipping_address'   => $shipping_address,
					'shipping_method'    => $order_info['shipping_method'],
					'product'            => $product_data,
					'comment'            => nl2br($order_info['comment'])

Newbie

Posts

Joined
Thu Nov 04, 2010 11:14 pm
Location - kanasa

Post by fido-x » Wed Nov 19, 2014 8:48 am

OK. You're using the release version of OC 2, while I'm looking at a later version from GitHub.

In your case the following can be found at lines 1960 to 1970 (for the invoice) and at lines 2202 to 2212 (for the shipping docket):

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'];
} 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');
}
Replace both with:

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'];
      if (isset($store_info['config_logo']) && is_file(DIR_IMAGE . $store_info['config_logo'])) {
            $store_logo = $this->model_tool_image->resize($store_info['config_logo'], 100, 100);
       } else {
            $store_logo = $this->model_tool_image->resize('no_image.png', 100, 100);
       }
} 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');
       if ($this->config->get('config_logo') && is_file(DIR_IMAGE . $this->config->get('config_logo'))) {
            $store_logo = $this->model_tool_image->resize($this->config->get('config_logo'), 100, 100);
       } else {
            $store_logo = $this->model_tool_image->resize('no_image.png', 100, 100);
       }
}
At lines 2108 to 2128 (invoice) and at lines 2302 to 2318 (shipping) in the unchanged file, you'll find:

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,
	'email'              => $order_info['email'],
	'telephone'          => $order_info['telephone'],
	'shipping_address'   => $shipping_address,
	'shipping_method'    => $order_info['shipping_method'],
	'product'            => $product_data,
	'comment'            => nl2br($order_info['comment'])
);
insert

Code: Select all

'store_logo'         => $store_logo,
after

Code: Select all

'store_fax'          => $store_fax,
in both.

Then insert at line 17 in both admin/view/template/sale/order_invoice.tpl and admin/view/template/sale/order_shipping.tpl:

Code: Select all

<div class="pull-right"><img src="<?php echo $order['store_logo']; ?>" alt="<?php echo $order['store_name']; ?>" /></div>
This should give you the store logo on both the invoice and shipping dockets.

Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia

Post by ranu70 » Thu Nov 20, 2014 1:52 pm

Hi ,

I am using opencart 1.5.4 version and want to add logo in my invoice how can i do this ...?

Thanking you...!

New member

Posts

Joined
Tue Apr 01, 2014 12:31 pm

Post by fido-x » Sat Nov 22, 2014 9:34 pm

ranu70 wrote:Hi ,

I am using opencart 1.5.4 version and want to add logo in my invoice how can i do this ...?

Thanking you...!
Read the first post in this thread!

Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia
Who is online

Users browsing this forum: No registered users and 4 guests