Jump to content

Adding Order Status to the Invoice


Recommended Posts

It can be very useful to have the invoice mentionning order status, especially if an order was cancelled or reimbursed.
 
I'm trying to have an "Order Status" displayed in the Order Information Section below the carrier details (Invoice.tpl)
 
Adding to HTMLTemplateInvoice.php :

public function getCurrentStateFull($id_lang)
{
return Db::getInstance()->getRow('
SELECT os.`id_order_state`, os.`name`
FROM `'._DB_PREFIX_.'order_state_lang` os
LEFT JOIN `'._DB_PREFIX_.'orders` osl ON (osl.`current_state` = os.`id_order_state`)
WHERE osl.`id_lang` = '.(int)$id_lang.' AND os.`id_order_state` = '.(int)$this->current_state);
}

should make this information available for the invoice, then adding to Invoice.tlp :

<tr>
<td style="width: 50%">
<b>{l s='Order Status' pdf='true'}</b>
</td>
<td style="width: 50%">
{$current_state}
</td>
</tr>

should display it in the invoice.

 

There is a mistake somewhere though because nothing is displayed but the title : Order Status.

I'm not sure if something is missing in the code, if the place of the code is wrong, or if the procedure itself needs more ellaboration (override etc.)

 

I'd appreciate any expert help - Thanks !

Link to comment
Share on other sites

thank you much, it improves the situation : some digits are displayed - they correspond to the current_state number indeed

 

it means my logical sequence in HTMLTemplateInvoice.php is wrong : I want to display the name of the order status instead

 

how should the code be modified ?

Link to comment
Share on other sites

in fact, the procedure I mentionned earlier for HTMLTemplateInvoice.php is useless : we get exactly the same result with or without it through {$order->current_state} in Invoice.tlp

 

my question is :

  • how to display the value of "name" (the order status name stored in the table "order_state_lang" not available by requesting $order->name)
  • instead of "current_state" (the order status number code stored in the table "orders" and directly available by requesting $order->current_state)

considering that:

  • "name" table1 is linked to "current state" table2 via "id_order_state" table1 = "current_state" table2
  • AND that only "current_state" is linked to the order id (meaning that we need this logical chain between the 2 tables to link "name" to the order id)

 

getting this is not straightforward and my technical knowledge is not allowing me to find the solution despite having brainstormed a few days on it

can anyone help me with this issue please ? I'm sure it's not at all a difficult issue for anyone with programming skills - for someone with very basic programming skills, thinking outside the box is unobvious

thanks for taking the rescue challenge ! :)

  • Like 1
Link to comment
Share on other sites

  • 1 year later...

Hi taydox, thank you very much for your reply. As said in previous posts, {$order->current_state} only displays the ID number of the status, not the name, e.g. instead of "Order canceled", you get "7". 

Link to comment
Share on other sites

Try to use OrderStatus::getOrderStates($id_lang). This method returns an array of all states and you can filter out one.

Thank you, tuk66. When I replace {$order->current_state} with {OrderStatus::getOrderStates($id_lang)}, PDF won't load at all. I guess I am doing something wrong.  :rolleyes: 

Link to comment
Share on other sites

  • 4 years later...
  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...