Forums / General Questions / Company Name after Customer Name (instead of before)

Company Name after Customer Name (instead of before)

Views: 1,120

Results 1 to 4 of 4
2 Oct 2014, 5:07 PM
#1
dw08gm avatar

dw08gm

Totally Zenned

Join Date:
Sep 2008
Location:
DownUnder, overlooking South Pole.
Posts:
1,018
Plugin Contributions:
2

Company Name after Customer Name (instead of before)

Back in 2008, Dr Byte kindly provided a solution to display the company name after the customer name.

1. Edit /includes/functions/functions_customers.php. Around line 108 you'll see code that looks like this. Add the additional code as shown:
Code:

    if ( (ACCOUNT_COMPANY == 'true') && (zen_not_null($company))  && !strpos($fmt, '$company') ) {
      $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). 

As discussed in this closed thread:
https://www.zen-cart.com/showthread.php?104358-Customer-Address-Formatting-and-Company-Name

The code works but with one small problem, that if no company name is provided, a blank line will appear between the customer name and the address, which does not look good.

Having spent much of the day trying to fix this problem, I now seek help to remove the blank line when no company name is provided.

Thanks

3 Oct 2014, 11:51 AM
#2
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

Re: Company Name after Customer Name (instead of before)

Played with this on a local installation (zc 1.5.3).

I need to stress that I have NOT implemented DrByte's second part of the solution - the part which talks about editing the "address_format" table in phpMyAdmin.

I changed this

    if ( (ACCOUNT_COMPANY == 'true') && (zen_not_null($company)) ) { 
      $address_out = $company . $cr . $address_out; 
    }

to this

    if ( (ACCOUNT_COMPANY == 'true') && (zen_not_null($company))  && !strpos($fmt, '$company') ) {
      $address_out = $company . $cr . $address_out;
    } elseif ( (ACCOUNT_COMPANY == 'true') && (zen_not_null($company)) ) { 
      $address_out = $company . $cr . $address_out; 
    }

I placed test orders with company name specified and company name not specified - no errors reported.

Suggest you try this ONLY on a local installation but not on a live store.

I could be totally off course - but worth a try.

Frank

NOTE: We are sorry that Frank is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

8 Oct 2014, 7:16 AM
#3
dw08gm avatar

dw08gm

Totally Zenned

Join Date:
Sep 2008
Location:
DownUnder, overlooking South Pole.
Posts:
1,018
Plugin Contributions:
2

Re: Company Name after Customer Name (instead of before)

Thanks Frank, but your suggestion did not seem to do anything different.

One solution I am working on atm is duplicating the address_book table rows (6 in 151, 7 in 153), and including the $company$cr after the customer names in the 7 copied rows. All I need to do is to devise an IF statement that if a company name exists, then use the number of the address format for the customer country +7. So for Australia, instead of row 7 being used, row 14 will be used if a company name exists. Have not had great success with this as yet, but have not played with it since the weekend.

Off topic, I went to your demo site and was mildly disappointed that no login was available to see how you handled the various My Account pages. I am currently working towards including ABN, GST, GST exemption code inputs associated with the company name and a few other fixes pertinent to Aust conditions, although very much tailored to my peculiar fluid/responsive template.

Cheers

8 Oct 2014, 10:42 AM
#4
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

Re: Company Name after Customer Name (instead of before)

dw08gm:

Thanks Frank, but your suggestion did not seem to do anything different.

Yeah, can't work because $cr$company inserts a carriage return and then the company name. If the company name is non-existent then we are getting a blank line .....

dw08gm:

One solution I am working on atm is duplicating the address_book table rows (6 in 151, 7 in 153), and including the $company$cr after the customer names in the 7 copied rows. All I need to do is to devise an IF statement that if a company name exists, then use the number of the address format for the customer country +7. So for Australia, instead of row 7 being used, row 14 will be used if a company name exists. Have not had great success with this as yet, but have not played with it since the weekend.

Please let us know how this pans out.

dw08gm:

Off topic, I went to your demo site and was mildly disappointed that no login was available to see how you handled the various My Account pages....

I didn't grant access to the admin because I am using this demo site for some other mod testing. Too much time involved restricting all the different configs to a demo admin. Sorry about that...

Cheers / Frank

NOTE: We are sorry that Frank is no longer with us.
We are grateful for all his contributions to the Zen Cart community.