What is the SKU variable to use in the templates

What is the variable for the SKU in both the invoice and quote templates.

Thanks

Yeah, thats my problem too. I need the variable or just someone who can tell me whats to do :wink:
@Kovah can you help us?

I achieved like this…

  1. Alter a table ip_invoice_items ( add a column called item_sku with varchar(50) )
  2. enable the mysql event scheduler

SET GLOBAL event_scheduler = ON;

  1. create a event in mysql to update the item_sku column for every 60 seconds.

CREATE EVENT update_status_test
ON SCHEDULE EVERY 60 SECOND
DO
update ip_invoice_items ipii, ip_products ipp set ipii.item_sku = ipp.product_sku
where ipp.product_description = ipii.item_description
and ipp.product_name = ipii.item_name and item_sku is null

  1. add this in your default.php

echo $item->item_sku

The solution itkamaraj gave does indeed work.
It would be nice if the product sku was available out of the box though as in many business cases it may be more appropriate to have then likewise.

It should be an option in the system settings for invoices and quotes.

Just a small hint: you can take a look at all available variables for templates. There is an own section for this in the wiki: https://wiki.invoiceplane.com/en/1.0/templates/customize-templates

@Kovah,

Any chance that in the future the item_sku variable will be available in the pdf template?

Not before InvoicePlane 2.

Thanks, any idea when InvoicePlane 2 will be born?

Nope, I only have little time to work on the app.

Here’s another solution to this if someone is having issues with the event scheduler (I’m in a shared hosting). My brother gave me a hand with this. I wanted to use the SKU specifically for invoices.

  1. Used step 1 solution from itkamaraj > Alter a table ip_invoice_items ( add a column called item_sku with varchar(50) )

  2. Then my brother added the following lines to the ajax.php file under /application/modules/invoices/controllers
    (specifically under the Save Function - see image).
    $productResult = $this->db->select(‘product_sku’)->from(‘ip_products’)->where(‘product_id’, $item->item_product_id)->limit(1)->get()->row_array();
    $item->item_sku = $productResult[‘product_sku’];

  3. Went into my custom invoice and added the following code where I wanted SKU data to be shown:

<?php echo $item->item_sku; ?>

This did the job. Hope this helps to others. Thank you itkamaraj and others.

1 Like

adding

<?php print_r($item); ?>

just before the closing </body> of the template shows the variable needed to display the SKU
in my case: [product_sku] => BIO-INFO

SKU can therefore be added in the item table using:

<td><?php _trans($item->product_sku); ?></td>