Dear All,
I would appreciated if anyone can let me know what file, and stpes to add SKU code to be displayed on PRODUCT INVOICE.
I have tried and added SKY CODE perfectly to product page, however, i got error "Notice: Undefined index: sku in C:\AppServ\www\upload\admin\controller\sale\order.php on line 1327".
The column SKU displayed OK. THE value SKU CODE does not.
Please let me know if you have any idea what i should do.
Cheers,
Felizone
I would appreciated if anyone can let me know what file, and stpes to add SKU code to be displayed on PRODUCT INVOICE.
I have tried and added SKY CODE perfectly to product page, however, i got error "Notice: Undefined index: sku in C:\AppServ\www\upload\admin\controller\sale\order.php on line 1327".
The column SKU displayed OK. THE value SKU CODE does not.
Please let me know if you have any idea what i should do.
Cheers,
Felizone
Not so simple because the Invoice gets it's data from the Order_product table which doesn't store the sku only:
order_id
product_id
name
model
quantity
price
total
tax
order_id
product_id
name
model
quantity
price
total
tax
Thanks for your reply.uksitebuilder wrote:Not so simple because the Invoice gets it's data from the Order_product table which doesn't store the sku only:
order_id
product_id
name
model
quantity
price
total
tax
I just want to add the SKU to invoice only , NOT other places.
Any simple coding?
Thanks.
I see the SKU is not be stored same place as Product code, it only stored in "PRODUCT" table.felizone wrote:Thanks for your reply.uksitebuilder wrote:Not so simple because the Invoice gets it's data from the Order_product table which doesn't store the sku only:
order_id
product_id
name
model
quantity
price
total
tax
I just want to add the SKU to invoice only , NOT other places.
Any simple coding?
Thanks.
How can i get it?
"ECHO" from product table???????
Thanks.
Never worked with PHP before, but I looked into the architecture and this isn't hard to do.
Not taking any responsibility and just giving the basics.
in admin/model/sale/order.php find
You need to edit that query with a JOIN to get the SKU from another table.
Then you have to add the sku to the product array
in admin/controller/sale/order.php find
There you insert
Also in the invoice() function on same page you have to insert something like
$this->data['column_sku''] = $this->language->get('sku'); or just
$this->data['column_sku'] = 'SKU'; if you dont want to edit the language files, this is for the column header
Now you can use the variables $column_sku and $product['sku'] in your template
Please have in mind I am not a PHP developer but this is how I would TRY it , back-ups are advised.
Not taking any responsibility and just giving the basics.
in admin/model/sale/order.php find
Code: Select all
public function getOrderProducts($order_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_product WHERE order_id = '" . (int)$order_id . "'");
return $query->rows;
}
Then you have to add the sku to the product array
in admin/controller/sale/order.php find
Code: Select all
$product_data[] = array(
'name' => $product['name'],
'model' => $product['model'],
'option' => $option_data,
'quantity' => $product['quantity'],
'price' => $this->currency->format($product['price'], $order_info['currency_code'], $order_info['currency_value']),
'total' => $this->currency->format($product['total'], $order_info['currency_code'], $order_info['currency_value'])
);
Code: Select all
'sku' => $product['sku'],
$this->data['column_sku''] = $this->language->get('sku'); or just
$this->data['column_sku'] = 'SKU'; if you dont want to edit the language files, this is for the column header
Now you can use the variables $column_sku and $product['sku'] in your template
Please have in mind I am not a PHP developer but this is how I would TRY it , back-ups are advised.
Got you the query, tested in in phpmyadmin and works OK
Let me know if it works and also try if it works when a product has no SKU.. thats why I didn't do an INNER JOIN.
Code: Select all
public function getOrderProducts($order_id) {
$query = $this->db->query("SELECT a.*, b.sku FROM " . DB_PREFIX . "order_product a LEFT JOIN " . DB_PREFIX . "product b ON a.product_id = b.product_id WHERE order_id = '" . (int)$order_id . "'");
return $query->rows;
}
I am release extension SKU in INVOICE, perhaps that suitable for you. Please check link below:
http://www.opencart.com/index.php?route ... on_id=2646
http://www.opencart.com/index.php?route ... on_id=2646
Oops.... It works perfect.Teyno wrote:Got you the query, tested in in phpmyadmin and works OK
Let me know if it works and also try if it works when a product has no SKU.. thats why I didn't do an INNER JOIN.Code: Select all
public function getOrderProducts($order_id) { $query = $this->db->query("SELECT a.*, b.sku FROM " . DB_PREFIX . "order_product a LEFT JOIN " . DB_PREFIX . "product b ON a.product_id = b.product_id WHERE order_id = '" . (int)$order_id . "'"); return $query->rows; }
Teyno, YOU ARE MY SUPER STAR.
Appreciated your time.
Have a nice day. Cheers...
Thanks, but it's not suitable for me to show SKU all around.nosecret wrote:I am release extension SKU in INVOICE, perhaps that suitable for you. Please check link below:
http://www.opencart.com/index.php?route ... on_id=2646
Thanks.
I need to get my SKU on my invoices as well but I want to make sure I am understanding these instructions correctly before I start to fiddle.
1. I would edit the files as stated above.
2. Then run the query on my database thru PHPmyAdmin.
Let me know if I got this right so I can give it a go. Thanks!
1. I would edit the files as stated above.
2. Then run the query on my database thru PHPmyAdmin.
Let me know if I got this right so I can give it a go. Thanks!
A HOW-To has been created to add SKU numbers to the Invoice. It was done to version 1.5.2.1.
It can be found here:
http://forum.opencart.com/viewtopic.php?f=121&t=57412
It can be found here:
http://forum.opencart.com/viewtopic.php?f=121&t=57412
A good site for e-commerce advice.
Hi Teyno,
perfect works like a charm. I have created an very complicated way see post http://forum.opencart.com/viewtopic.php ... 878#p90940
I am no SQL expert, I was thinking about a join function as well, just did not know how to write it, you did it. Big thanks!
I am now migrating from 147 to 156 so had to rewrite all the functions, this saves me a lots of time and it is also future proof!
Here my vqmod file to add skus on invoice.
just save this code as .xml and upload to vqmod/xml folder
... yes for this you need to install vqmod, but better then modify base files...
-- or just search for the above statements in <search></search> and add / replace as stated in the code..
@ Teyno - thanks Mister
perfect works like a charm. I have created an very complicated way see post http://forum.opencart.com/viewtopic.php ... 878#p90940
I am no SQL expert, I was thinking about a join function as well, just did not know how to write it, you did it. Big thanks!
I am now migrating from 147 to 156 so had to rewrite all the functions, this saves me a lots of time and it is also future proof!
Here my vqmod file to add skus on invoice.
Code: Select all
<modification>
<id>SKUs on Invoice</id>
<version>1.0.0</version>
<vqmver>1.0.8</vqmver>
<author>Bedo & Teyno :)</author>
<file name="admin/model/sale/order.php">
<operation>
<search position="replace"><![CDATA[$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_product WHERE order_id = '" . (int)$order_id . "'");]]></search>
<add><![CDATA[
$query = $this->db->query("SELECT a.*, b.sku FROM " . DB_PREFIX . "order_product a LEFT JOIN " . DB_PREFIX . "product b ON a.product_id = b.product_id WHERE order_id = '" . (int)$order_id . "'");
]]></add>
</operation>
</file>
<file name="admin/controller/sale/order.php">
<operation>
<search position="after"><![CDATA['model' => $product['model'],]]></search>
<add><![CDATA[
'sku' => $product['sku'],
]]></add>
</operation>
</file>
<file name="admin/view/template/sale/order_invoice.tpl">
<operation>
<search position="before"><![CDATA[<td><b><?php echo $column_product; ?></b></td>]]></search>
<add><![CDATA[
<td><b><?php echo 'SKU'; ?></b></td>
]]></add>
</operation>
<operation>
<search position="before"><![CDATA[<td><?php echo $product['name']; ?>]]></search>
<add><![CDATA[
<td><?php echo $product['sku']; ?></td>
]]></add>
</operation>
<operation>
<search position="replace"><![CDATA[<td align="right" colspan="4"><b><?php echo $total['title']; ?>:</b></td>]]></search>
<add><![CDATA[
<td align="right" colspan="5"><b><?php echo $total['title']; ?>:</b></td>
]]></add>
</operation>
</file>
</modification>
... yes for this you need to install vqmod, but better then modify base files...
-- or just search for the above statements in <search></search> and add / replace as stated in the code..
@ Teyno - thanks Mister
using oc 1.5.6
Hi there,
I'd love to have this functionality on our admin order invoice page but when I upload the xml file detailed above I just get an error "Warning: VQMod script XML syntax is invalid! Please contact the author for support." and nothing happens.
Are you able to advise on what might be wrong?
Best wishes
Andy
I'd love to have this functionality on our admin order invoice page but when I upload the xml file detailed above I just get an error "Warning: VQMod script XML syntax is invalid! Please contact the author for support." and nothing happens.
Are you able to advise on what might be wrong?
Best wishes
Andy
Can you please post your entire XML here?
Donate here to show support if you think I have helped you today!
Opencart Documentation
Confirming that the mods tutored by teyno works perfect on 1.5.6.4
Im uploading my files to help others like myself who dont know a zilch on coding but would like to have sku
just upload to your home directory and unzip, the files will go sit in their respective places...
How it works
SKU returned for items with SKU
Blank SKU column for items without SKU
disclaimer - you are responsible for your actions. Kindly back up your admin folder before doing this ... it worked flawless for me but I can no way assure the same for you....(Yet I am sure it will)
Im uploading my files to help others like myself who dont know a zilch on coding but would like to have sku
just upload to your home directory and unzip, the files will go sit in their respective places...
How it works
SKU returned for items with SKU
Blank SKU column for items without SKU
disclaimer - you are responsible for your actions. Kindly back up your admin folder before doing this ... it worked flawless for me but I can no way assure the same for you....(Yet I am sure it will)
Attachments
All files with the mods indicated by teyno works for me on 1.5.6.4 on a heavily customised theme
Who is online
Users browsing this forum: No registered users and 99 guests