Jump to content

How to put state name variable in invoice?


danodas

Recommended Posts

Prestashop 1.6.1.4
Hi!
I have a problem that I can't solve at all for 3 days.
I created an invoice template that works for me (in Romania), except that I can not bring the state in this Invoice.
I have everything I need there but I tried a lot of combinations for state variable:
$address->state, $addresses.invoice->state and others an it brings to me a blank space.
 
Please help me!!!
 
This is the part of the code I use for customer data (city, state, country) and, as I told you, every variable is putted correctly on the invoice, except the one in red, what should be the state of the customer from address.
 



{$addresses.invoice->city},State: {$addresses.invoice->state},{$addresses.invoice->country},<br>


 
 ----------------------------------------------------------------------------------------------------------------------------
 
[sOLVED]

The solution was given by tuk66 and is: 

{State::getNameById({$addresses.invoice->id_state})}

Edited by danodas (see edit history)
Link to comment
Share on other sites

Thank you.

I have all the settings ok. The addresses tabs apear OK in BO and FO but not in invoice. I am not using $addresses_tab variable in template.

For custom purposes, I use every smarty variable I can in my template.

I put the template here, you all can use it. It's for NON VAT Romania shop.

 

The template is here

 

invoice.zip

 

 

And a picture with the problem is here:

 

post-1211875-0-52481400-1460308583_thumb.png

 

 

As you can see, all variables are resulting ok, except the state, it should be Ex. Neamt  or Alabama... Anything.

Edited by danodas (see edit history)
Link to comment
Share on other sites

Try to create a new order and you will see. Can be that state is only missing in old orders.

 

Nope! Same problem. Thank you anyway for your time!

 

I created a new acount and place a new order. In addresses tab in Front and BackOffice the address is OK (with state). All settings are and were corect.

No state output for variable in invoice. Maybe I don't use the right variable. I use {$addresses.invoice->state}.

 I tried {$addresses.invoice->state_name}, {$addresses.invoice->name}, {$addresses.invoice->sname}, {$addresses.invoice->statename}.

If I put {$addresses.invoice->id_state} it write the ID of the state in invoice. But... I realy need the name of the state.

It's so frustrating. Everything I have done by my self and I am not a php-html programmer, but this...?

I don't know... How can I extract in invoice.tpl the name of the state based on id_state from state table? Can you help me with a script or something.

HELP!

Same result over and over.

Edited by danodas (see edit history)
Link to comment
Share on other sites

Try this static method - State::getNameById($id_state).

 

To be fully sure, I would also check if the address has set id_state.

 

Finally!

It works with {State::getNameById({$addresses.invoice->id_state})}

THANK YOU SO MUCH!

Link to comment
Share on other sites

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...