TechBook will reward the Top Ten Users for the month of October with a One Year FREE Web Hosting Account

How to Add Store logo to your opencart store Invoice

Post Reply
chival
Newbie on TechBook
Posts: 18
Joined: Wed Jul 26, 2017 1:15 am
Membership Category: Techie/Freelancer

How to Add Store logo to your opencart store Invoice

Post by chival » Tue Aug 15, 2017 4:18 pm

How to Add Store logo to your opencart store
In this blog post you will learn how to add your store logo and product images to your invoices, changing the default OpenCart 2.x invoice template.

Unfortunately, OpenCart has not built-in editor for editing invoice template within the admin panel and we have to change it by modifying the code itself.

Note: This modification works only with OpenCart 2.x and we assume that you have already installed it.

OCMod modification
Since modifying core files is not recommended, because of other modules malfunctioning, we will use OCMod modification to edit the template for the invoices.

This method does not modify the core functionality of OpenCart and this is why we are going to use this one.

First thing you should do is to create a new XML file and name it yourcustommodificationname.ocmod.xml. Please, make sure that your file has the extension .ocmod.xml, because otherwise it won’t be recognized by the integrated Extension installer in OpenCart 2.x.

Add logo in the header
If we want to include the logo in the header of the invoice, we need to add these lines in the file:

Code: Select all

<modification>
    <name>Add images to invoice by iSenseLabs</name>
	<version>1.0 (Initial)</version>	
	<link>https://isenselabs.com</link>
	<code>isense_invoice</code>
	<author>iSenseLabs</author>

	<file path="admin/controller/sale/order.php">
		<operation>
			<search><![CDATA[public function invoice() {]]></search>
			<add position="after"><![CDATA[
				// ISENSELABS.COM CODE STARTS HERE
				$this->load->model('tool/image');
				// ISENSELABS.COM CODE ENDS HERE
			]]></add>
		</operation>

		<operation>
			<search index="0"><![CDATA[$this->response->setOutput($this->load->view('sale/order_invoice]]></search>
			<add position="before"><![CDATA[
				// ISENSELABS.COM CODE STARTS HERE
		
				if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) {
					$server = $this->config->get('config_ssl');
				} else {
					$server = $this->config->get('config_url');
				}
				
				if ($this->config->get('config_logo') && file_exists(DIR_IMAGE . $this->config->get('config_logo'))) {
					$data['logo'] = $server . 'image/' . $this->config->get('config_logo');
				} else {
					$data['logo'] = '';
				}
				
				// ISENSELABS.COM CODE ENDS HERE
			]]></add>
		</operation>
	</file>

	<file path="admin/view/template/sale/order_invoice.tpl">
		<operation>
			<search><![CDATA[<div style="page-break-after: always;">]]></search>
			<add position="after"><![CDATA[
				<!-- ISENSELABS.COM CODE STARTS HERE -->

				<?php if(isset($logo) && !empty($logo)) { ?>
            		<img src="../<?php echo $logo ?>" style="margin: 15px 0 15px 0;" />
           		<?php } ?>

				<!-- ISENSELABS.COM CODE ENDS HERE -->
			]]></add>
		</operation>
	</file>
</modification>
Then, we should go to your OpenCart Store Administration Page > Extensions > Extension Installer and upload the file. After we get the message ‘Success: You have installed your extension!’, we need to go to Extensions > Modifications and click on the Refresh button to apply the changes.

Post Reply
kuchnie kraków opinie

Who is online

Users browsing this forum: No registered users and 1 guest