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

Open to all! Ask other shopowners for help.
Post Reply
loop
Contributor
Posts: 253
Joined: Thu Mar 25, 2021 12:26 pm
Phoenix Version:
Has thanked: 7 times
Been thanked: 3 times

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

Post 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


Join The Code Co-op to get access to your library in the Code Co-op Forum
User avatar
ReneH4
Contributor
Posts: 145
Joined: Mon Oct 26, 2020 12:00 pm
Phoenix Version:
Has thanked: 13 times
Been thanked: 17 times

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

Post by ReneH4 »

In Admin go to Locationa and taxes > Countries

Fot every country you can set the address format. I think you need 5.
loop
Contributor
Posts: 253
Joined: Thu Mar 25, 2021 12:26 pm
Phoenix Version:
Has thanked: 7 times
Been thanked: 3 times

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

Post 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?)
User avatar
ReneH4
Contributor
Posts: 145
Joined: Mon Oct 26, 2020 12:00 pm
Phoenix Version:
Has thanked: 13 times
Been thanked: 17 times

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

Post 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.
Last edited by ReneH4 on Thu Jul 14, 2022 6:26 am, edited 1 time in total.
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

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

Post 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>');
loop
Contributor
Posts: 253
Joined: Thu Mar 25, 2021 12:26 pm
Phoenix Version:
Has thanked: 7 times
Been thanked: 3 times

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

Post 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?
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

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

Post by ecartz »

The address_format_id is stored in the orders table for existing orders; once for each address.


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply