Zen Cart Logo
Forums / Managing Customers and Orders / Customer Address Formatting and Company Name

Customer Address Formatting and Company Name

Locked

Views: 3,210

Results 1 to 8 of 8
This thread is locked. New replies are disabled.
1 Aug 2008, 6:54 PM
#1
dkoehler avatar

dkoehler

New Zenner

Join Date:
Jul 2008
Posts:
19
Plugin Contributions:
0

Customer Address Formatting and Company Name

I'd like to change the way Zen Cart represents mailing/shipping addresses of customers who provide a company name. By default, it looks like this:

Company Name
Customer Name
Street Address
City, etc...

To me, at least, the following makes much more sense:

Customer Name
Company Name
Street Address
City, etc...

I searched the forums and came across a posting on how to move Company Name from the very top to the very bottom of the address, but to me that would seem to make even less sense than the current default. Because that solution involved modifying a ZC function that tacked on the optional Company Name to the top of a pre-existing variable representing the (entire) address, there's no obvious variant of that solution that would do what I want (I don't think, anyway, as what I want would involve inserting Company Name--if specified--into the middle of that address variable).

I could probably get (roughly) what I want by removing the Company Name altogether from the address (via a variant of the posted solution mentioned above) and then specifying in the address fields that, say, Street Address Line 1 could be the Company Name (and then use Street Address Line 2 for the Company's street address), but I wondered if there might be a simpler, more elegant solution.

Any ideas?

1 Aug 2008, 7:41 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Customer Address Formatting and Company Name

You might be able to accomplish your desired goal with a couple fairly simple steps.
The following might work:

  1. Edit /includes/functions/functions_customers.php. Around line 108 you'll see code that looks like this. Add the additional code as shown:```
    if ( (ACCOUNT_COMPANY == 'true') && (zen_not_null($company)) [B]&& !strpos($fmt, '$company')[/B] ) {
    $address_out = $company . $cr . $address_out;
    }

2. Using phpMyAdmin, open the "address_format" table, and edit the value in the address_format column for address_format_id record #2 by adding $cr$company right after $lastname

That will affect all addresses for all customers whose country's standard address formatting is set to address_format_id #2  (USA is set to use #2 by default).
1 Aug 2008, 8:19 PM
#3
dkoehler avatar

dkoehler

New Zenner

Join Date:
Jul 2008
Posts:
19
Plugin Contributions:
0

Re: Customer Address Formatting and Company Name

Thanks, Dr. Byte, that seems to have worked perfectly!

I thought this line ...

$address_out = $company . $cr . $address_out;

... was going to continue to tack on the Company Name at the top of the address (in addition to the one now inserted below Customer Name), but--magically--it didn't!

Thanks again for your help.

1 Aug 2008, 8:45 PM
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Customer Address Formatting and Company Name

That's what the code change was for :)

Glad it worked for you.

16 Aug 2008, 6:48 PM
#5
dkoehler avatar

dkoehler

New Zenner

Join Date:
Jul 2008
Posts:
19
Plugin Contributions:
0

Re: Customer Address Formatting and Company Name

The solution suggested by DrByte produced the address formatting I wanted in the e-mails sent to the customer referencing their orders:

Customer Name
Company Name
Street Address, etc.

But now I've noticed that, on the orders page, invoice, and packing slip functions generated through the admin console, the company name appears twice:

Company Name
Customer Name
Company Name
Street Address, etc.

Any suggestions on how to correct this would be appreciated.

17 Aug 2008, 4:12 AM
#6
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Customer Address Formatting and Company Name

A change to the files producing those outputs , similar to what you did to functions_customers.php, would probably resolve the issue. The concept is the same. The actual code to change may or may not be different, but will certainly be in different files.

17 Aug 2008, 5:44 PM
#7
dkoehler avatar

dkoehler

New Zenner

Join Date:
Jul 2008
Posts:
19
Plugin Contributions:
0

Re: Customer Address Formatting and Company Name

Thanks. I'm having some trouble figuring out which files are responsible for generating those fields on the invoice and packing slip, but will keep looking and post whatever I discover (if anything).

17 Aug 2008, 6:20 PM
#8
dkoehler avatar

dkoehler

New Zenner

Join Date:
Jul 2008
Posts:
19
Plugin Contributions:
0

Re: Customer Address Formatting and Company Name

Ah. That wasn't so complicated, after all. There is (as everybody but me probably already knows) a parallel functions_customers.php file in the admin/includes/functions directory, and making the same code change suggested by DrByte above fixes the problem I was having with invoice, packing slip, etc. in the admin interface.