Page 1 of 1

How to change "format" of the address in orders.php?

Posted: Thu Jul 14, 2022 5:33 am
by loop
hi All
can somebody point me to the right direction:

in orders.php there ist $address->format

How can i change this format?
i need
Firstname name
street
zipcode city

(instead of:
firstnam name
street
city, zipcode)

thanks

Re: how to change "format" of the adress in orders.php?

Posted: Thu Jul 14, 2022 5:50 am
by ReneH4
In Admin go to Locationa and taxes > Countries

Fot every country you can set the address format. I think you need 5.

Re: how to change "format" of the adress in orders.php?

Posted: Thu Jul 14, 2022 6:06 am
by loop
hi! i tried both:
to change in the admin in the country and also in the function itself (in orders.php)
echo $address->format($order->customer, 1, '', '<br>'); like echo $address->format($order->customer, 5, '', '<br>');

but it does not change the format of the adress in orders.php (or is it only on new orders? and not on already saved orders?)

Re: how to change "format" of the adress in orders.php?

Posted: Thu Jul 14, 2022 6:25 am
by ReneH4
Loop, this is for new orders only. The format is used to store the address with the order into the database, so it will not change once the order is placed.

Re: how to change "format" of the address in orders.php?

Posted: Thu Jul 14, 2022 6:26 am
by ecartz
loop wrote: Thu Jul 14, 2022 6:06 am

Code: Select all

echo $address->format($order->customer, 1, '', '<br>');
echo $address->format($order->customer, 5, '', '<br>');
cd_traditional_address->format does not take a format_id argument. The second argument is the Boolean for whether to use HTML or plain text. Instead try

Code: Select all

echo $address->format(array_replace($order->customer, ['format_id' => 5]), 1, '', '<br>');

Re: How to change "format" of the address in orders.php?

Posted: Thu Jul 14, 2022 6:29 am
by loop
you are the best ecartz! thank you!
is the "old format_id" somewhere stored in the database so i could change this in the sql to 5?

Re: How to change "format" of the address in orders.php?

Posted: Thu Jul 14, 2022 6:36 am
by ecartz
The address_format_id is stored in the orders table for existing orders; once for each address.