Forums / All Other Contributions/Addons / Company Name after Customer Name Support

Company Name after Customer Name Support

Views: 1,418

Results 1 to 9 of 9
7 Aug 2015, 12:01 AM
#1
dw08gm avatar

dw08gm

Totally Zenned

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

Company Name after Customer Name Support

This is the support thread for Company Name after Customer Name mod about to be uploaded to plugins.

7 Aug 2015, 12:34 AM
#2
drbyte avatar

drbyte

Sensei

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

Re: Company Name after Customer Name Support

While I understand that someone wanted to inject the company name for their specific site (I've read yaseent's thread), I'm having trouble understanding why one would want to do this universally.

  1. What's the specific business problem this is designed to solve?

  2. Is it really necessary to touch the address_format table at all? I mean, since you've injected the $injectCompany thing into every address format, why touch the database at all instead of just leaving it entirely in PHP?

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

7 Aug 2015, 12:48 AM
#3
dw08gm avatar

dw08gm

Totally Zenned

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

Re: Company Name after Customer Name Support

DrByte:

While I understand that someone wanted to inject the company name for their specific site (I've read yaseent's thread), I'm having trouble understanding why one would want to do this universally.

  1. What's the specific business problem this is designed to solve?

In normal business practice (at least in Commonwealth countries) addresses go from least to greatest scope - perfectly logical to me.

DrByte:

  1. Is it really necessary to touch the address_format table at all? I mean, since you've injected the $injectCompany thing into every address format, why touch the database at all instead of just leaving it entirely in PHP?

I am no expert in coding and am happy with what I have done. The issue has been raised several times over the years and as far as I am concerned has not been adequately resolved. If and when someone provides a better solution, I would be happy to adopt it.

Thanks

8 Aug 2015, 6:03 PM
#4
malaperth avatar

malaperth

New Zenner

Join Date:
Dec 2013
Location:
Maine
Posts:
77
Plugin Contributions:
0

Re: Company Name after Customer Name Support

dw08gm:

In normal business practice (at least in Commonwealth countries) addresses go from least to greatest scope - perfectly logical to me.

I am no expert in coding and am happy with what I have done. The issue has been raised several times over the years and as far as I am concerned has not been adequately resolved. If and when someone provides a better solution, I would be happy to adopt it.

Thanks

I may be wrong in my interpretation of Dr. Byte's second question, but it seems he is saying that you, yourself have already provided your "better solution" in the PHP code so that modifying the database at all is redundant and unnecessary.

Mal

9 Aug 2015, 5:51 AM
#5
dw08gm avatar

dw08gm

Totally Zenned

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

Re: Company Name after Customer Name Support

Altering the Db is the only solution I have been able to find that works properly.

I remain open to a better solution.

9 Aug 2015, 1:38 PM
#6
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,110
Plugin Contributions:
56

Re: Company Name after Customer Name Support

The only alternate solution that I came up with requires modification of the* zen_address_format* function, present in both SIZE=1[/SIZE] /YOUR_ADMIN/includes/functions/functions_customer.php and /includes/functions/functions_customer.php. Towards the end of each function, find this block:

    $fmt = $address_format->fields['format'];
    eval("\$address_out = \"$fmt\";");

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

    return $address_out;

and change by simply reordering the lines, to:

   $fmt = $address_format->fields['format'];
   if (ACCOUNT_COMPANY == 'true' && zen_not_null ($company)) {
      $fmt = str_replace ('$lastname$cr', '$lastname$cr$company$cr', $fmt);
    }
    eval("\$address_out = \"$fmt\";");
    
    return $address_out;
11 Aug 2015, 6:35 AM
#7
dw08gm avatar

dw08gm

Totally Zenned

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

Re: Company Name after Customer Name Support

Many Thanks Lat9

I tested your code and it works.

I shall upload a new version of the mod.

Cheers

11 Aug 2015, 10:49 AM
#8
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,110
Plugin Contributions:
56

Re: Company Name after Customer Name Support

No problem! I'm a big fan of minimizing core-file changes when it comes to plugins.