Address Format Manager - zip

Open to all! Ask other shopowners for help.
User avatar
burt
Core Team
Posts: 4551
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 412 times

Address Format Manager - zip

Post by burt »

Came across an older page I made in the very early days of CE/BS for a client. Updated to 1.0.8.20 standard.

It allows you to view/add/edit/delete Address Formats. For those who do not know, Address Formats are set on a country by country basis and are used to output the address in the format needed.
Free .zip no longer available

Just one set of brilliant feedback received, so away it goes.
I'll not waste my time on these little code drops.
Download this .zip, upload to your admin area and you will find a new Menu entry in Tools which will lead to the Address Format Manager page. Assigning existing Address Formats to countries is done in the admin/countries.php page.
I am not here to build for you.
I am here to build with you. Let's help each other.


Join The Code Co-op to get access to your library in the Code Co-op Forum
14Steve14
Senior Contributor
Posts: 922
Joined: Fri Oct 25, 2019 7:01 pm
Phoenix Version: v1.0.9.1
Has thanked: 17 times
Been thanked: 103 times

Re: Address Format Manager - zip

Post by 14Steve14 »

Gary

I just tested this and it works as I would expect when creating a new address format even if some of the variables were not really clear. I created a UK based address format and added the company name after the customers name. It sort of worked. I also added in suburb which dod as I hope dit would. I had it laid out as $name, $company, $street, $suburb, $city, $state, $postcode, $country. I maDe the UK as a country to use this address format.

The problems arouse when I looked at an old order that the customer had placed. It showed two company names. One above the customers name and one below the customers name. There was also a blank line in the address where the suburb line should be, but was empty in the address. Not too sure this line should show when it is empty. When the suburb was filled with something it seemed to work.

Not sure if it was just me or not but I thought I would report my findings.
User avatar
burt
Core Team
Posts: 4551
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 412 times

Re: Address Format Manager - zip

Post by burt »

Perfect, thanks for the feedback Steve :)
There was also a blank line in the address where the suburb line should be
This sounds correct, if the shop did not ask the customer for a suburb when he made his address.
Is it a bug? Possibly. I've not looked into that part of Phoenix ever, so it's likely an artifact "feature" from older osc. Would you add it into the Bug Hunt thread and I'll take a look in November.
when I looked at an old order that the customer had placed. It showed two company names. One above the customers name and one below the customers name.
The one under the name would be correct based on your new Address Format.

The one over the name is also "correct" (I think, based on a vague memory of old osc) where the Company is always placed at the top of the Address regardless of anything else in the Address Format. I can't remember why that is done, but it is ringing a bell. Add it into the same Bug Report please. It would all be to do with how address labels are formatted, so it's one area of "features" (ahem) to be looked at.
I am not here to build for you.
I am here to build with you. Let's help each other.
User avatar
burt
Core Team
Posts: 4551
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 412 times

Re: Address Format Manager - zip

Post by burt »

Here is the "Company" being added above the address in old Phoenix (which is near enough same as osc);

https://github.com/CE-PhoenixCart/Phoen ... #L507-L509

And in more modern Phoenix;

https://github.com/CE-PhoenixCart/Phoen ... #L144-L146

Basically both say;

if "company" exists;
add the "company" above the address

I'd be slightly loathe to change that as many shopowners would be so used to it, and it would suddenly cause issues (if they did not have $company in their address_format). I suppose the possibility is there to create a new Customer Data module, or maybe these CD modules can be over-ridden (I've never tried). IE, for shopkeeps like yourself who don't need that extra "company", override the file... I'm going to tag in Matt @ecartz just to ask if these modules can be easily overridden or would it necessitate a new module being created..or some other way!
I am not here to build for you.
I am here to build with you. Let's help each other.
User avatar
burt
Core Team
Posts: 4551
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 412 times

Re: Address Format Manager - zip

Post by burt »

14Steve14 wrote: Wed Oct 11, 2023 1:44 pm The problems arouse when I looked at an old order that the customer had placed. It showed two company names. One above the customers name
On a TEST SITE!...

Place a copy of
/includes/modules/customer_data/cd_traditional_address.php
=>
/includes/system/override/cd_traditional_address.php

You may need to create the override folder.
Note; This override folder is NOT connected to the override template.
Next, open up this new file /includes/system/override/cd_traditional_address.php

and comment out these lines (approx lines 144 - 146), as so;

//if (!empty($company)) {
// $address = $company . $cr . $address;
//}

Check customer address (eg in an order, or address book etc).
The extra "company" above the address should be gone.
Note; you would now need to ensure that ALL of your address formats have $company somewhere in them. This would be done in the new address_format.php admin page.
I am not here to build for you.
I am here to build with you. Let's help each other.
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: Address Format Manager - zip

Post by ecartz »

burt wrote: Wed Oct 11, 2023 2:10 pm I'm going to tag in Matt @ecartz just to ask if these modules can be easily overridden or would it necessitate a new module being created..or some other way!
I don't know about overriding customer data modules. Others have successfully overridden other modules, so it's probably possible.

That said, you could easily enough copy cd_traditional_address.php to (e.g.) cd_address_a_la_burt.php, fix the naming, and uninstall cd_traditional_address.php and replace it with cd_address_a_la_burt.php

For an add-on, you could provide the files for cd_address_a_la_burt.php and then put the bit about uninstalling and installing in the instructions.

The code about the company is at https://github.com/CE-PhoenixCart/Phoen ... #L144-L146

In the longer term, we could add a new address module to core but default existing installations to use the old module. Then set new installs to use the new module and drop the old module from core (but not delete it from existing installations, which might still be using it).
User avatar
burt
Core Team
Posts: 4551
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 412 times

Re: Address Format Manager - zip

Post by burt »

ecartz wrote: Sun Oct 15, 2023 9:26 pm I don't know about overriding customer data modules. Others have successfully overridden other modules, so it's probably possible.
Overriding CD modules seems to work. EG copying to /includes/system/override.

The language constants get lost though.

Placing a copy of the relevant language file to /includes/languages/english/system/override/ fixes it.
I am not here to build for you.
I am here to build with you. Let's help each other.
raiwa
Certified Developer
Posts: 1640
Joined: Sat Dec 21, 2019 8:08 am
Phoenix Version: 1.1.0.6
Has thanked: 70 times
Been thanked: 152 times

Re: Address Format Manager - zip

Post by raiwa »

I can confirm this. Did it in a livestore for several modules.
Public Phoenix Change Log Cheat Set on Google Sheets
https://docs.google.com/spreadsheets/d/ ... sp=sharing

Need Help?viewtopic.php?f=10&t=27
14Steve14
Senior Contributor
Posts: 922
Joined: Fri Oct 25, 2019 7:01 pm
Phoenix Version: v1.0.9.1
Has thanked: 17 times
Been thanked: 103 times

Re: Address Format Manager - zip

Post by 14Steve14 »

burt wrote: Wed Oct 11, 2023 2:03 pm Perfect, thanks for the feedback Steve :)
There was also a blank line in the address where the suburb line should be
This sounds correct, if the shop did not ask the customer for a suburb when he made his address.
Is it a bug? Possibly. I've not looked into that part of Phoenix ever, so it's likely an artifact "feature" from older osc. Would you add it into the Bug Hunt thread and I'll take a look in November.
Gary. When a customer creates an account Suburb is an option and the customer data module cd_suburb.php is installed. As there is no suburb in the address it was left blank. I would have thought that as the line was blank the line should not show in the address.

Removing this addons code and reverting back to the original address format, the address shows as it should in admin and invoices, and blank lines are removed.
User avatar
burt
Core Team
Posts: 4551
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 412 times

Re: Address Format Manager - zip

Post by burt »

Great thanks Steve. Massively appreciate you being the only one who could take the time to provide some feedback.

I don't want to get into the realms of changing core code to accommodate this addon, so I think if you change the language define (admin/includes/languages/english/address_format.php) to;

Code: Select all

const TEXT_HELPER_VARIABLES_ARRAY = [
'$company' => 'Company Name',
'$name' => 'Customer Name',
'$streets' => 'Delivery Street Address (inc suburb if activated)',
'$city' => 'Delivery City',
'$state' => 'Delivery State',
'$statecomma' => 'Delivery State (with trailing comma)',
'$postcode' => 'Delivery Postcode',
'$country' => 'Delivery Country',
];
And then use only these (ie I've removed $street and $suburb and $zip), it should be OK. $streets seem to be programmatically made by combining $street and $suburb.
I am not here to build for you.
I am here to build with you. Let's help each other.


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