Simple coding SKU ON INVOICE
14 posts
• Page 1 of 1
Simple coding SKU ON INVOICE
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

- felizone
- Posts: 59
- Joined: Thu Apr 08, 2010 7:28 am
Re: Simple coding SKU ON INVOICE
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
Happy Coding!
Simon
------
Commercial Mods:
Google Merchant / Base XML Feed + Bing Shopping + Sitemaps - Automatic Friendly SEO URLs
Full List of UKSB Extensions and Mods
vQmod Generator - Develop & Test OpenCart on your Local Windows machine
Click here if I have helped you and you would like to make a donation
Simon
------
Commercial Mods:
Google Merchant / Base XML Feed + Bing Shopping + Sitemaps - Automatic Friendly SEO URLs
Full List of UKSB Extensions and Mods
vQmod Generator - Develop & Test OpenCart on your Local Windows machine
Click here if I have helped you and you would like to make a donation
-

uksitebuilder - Posts: 5602
- Joined: Thu Jun 09, 2011 3:37 pm
- Location: United Kindgom
Re: Simple coding SKU ON INVOICE
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
Thanks for your reply.
I just want to add the SKU to invoice only , NOT other places.
Any simple coding?
Thanks.

- felizone
- Posts: 59
- Joined: Thu Apr 08, 2010 7:28 am
Re: Simple coding SKU ON INVOICE
felizone wrote: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
Thanks for your reply.
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.
How can i get it?
"ECHO" from product table???????
Thanks.
- felizone
- Posts: 59
- Joined: Thu Apr 08, 2010 7:28 am
Re: Simple coding SKU ON INVOICE
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;
}
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
- 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'])
);
There you insert
- Code: Select all
'sku' => $product['sku'],
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.- Teyno
- Posts: 31
- Joined: Tue Dec 06, 2011 9:37 am
Re: Simple coding SKU ON INVOICE
Apprecaited Teyno.
I will give a try.
I will post if it works for me.
Thank you.
I will give a try.
I will post if it works for me.
Thank you.
- felizone
- Posts: 59
- Joined: Thu Apr 08, 2010 7:28 am
Re: Simple coding SKU ON INVOICE
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;
}
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.- Teyno
- Posts: 31
- Joined: Tue Dec 06, 2011 9:37 am
Re: Simple coding SKU ON INVOICE
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
Module : Shop by Material 1.5 | Shop by Color 1.5 | Shop by Size 1.5 | Coming Soon and Most Viewed Modules 1.5
Modification : SKU in INVOICE 1.5
Modification : SKU in INVOICE 1.5
- nosecret
- Posts: 219
- Joined: Tue Dec 28, 2010 4:28 am
Re: Simple coding SKU ON INVOICE
Teyno wrote:Got you the query, tested in in phpmyadmin and works OK
- 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;
}
Let me know if it worksand also try if it works when a product has no SKU.. thats why I didn't do an INNER JOIN.
Oops....
It works perfect.Teyno, YOU ARE MY SUPER STAR.
Appreciated your time.
Have a nice day. Cheers...

- felizone
- Posts: 59
- Joined: Thu Apr 08, 2010 7:28 am
Re: Simple coding SKU ON INVOICE - Solved
It shows nothing there if product has no SKU.
Will this a bug? I think no...
It works perfect for me.
Thank you. Teyno
Will this a bug? I think no...
It works perfect for me.
Thank you. Teyno
- felizone
- Posts: 59
- Joined: Thu Apr 08, 2010 7:28 am
Re: Simple coding SKU ON INVOICE
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, but it's not suitable for me to show SKU all around.
Thanks.
- felizone
- Posts: 59
- Joined: Thu Apr 08, 2010 7:28 am
Re: Simple coding SKU ON INVOICE - Solved
felizone wrote:It shows nothing there if product has no SKU.
Will this a bug? I think no...
It works perfect for me.
Thank you. Teyno
Your very welcome..

- Teyno
- Posts: 31
- Joined: Tue Dec 06, 2011 9:37 am
Re: Simple coding SKU ON INVOICE
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!

- afonte
- Posts: 20
- Joined: Thu Feb 09, 2012 2:50 pm
Re: Simple coding SKU ON INVOICE
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:
viewtopic.php?f=121&t=57412
It can be found here:
viewtopic.php?f=121&t=57412
A good site for e-commerce advice.
- H2O
- Posts: 26
- Joined: Tue Feb 28, 2012 11:36 pm
14 posts
• Page 1 of 1
Who is online
Users browsing this forum: hashmat, SimplyToyz and 78 guests













