Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

trying to adjust this address layout function


Feedbag

Recommended Posts

Posted

this function is from general.php

 

My problem is, when it prints out the address to an invoice, it always puts company first, before the name, which is wrong. company should come after the name. Unfortunately, you'll notice at the bottom of the code, company is optional, so its added as an "if", and then just pastes it first, then uses the already written function to display the rest of the address after it.

 

I need it to format it so the first and last name are on the first line, then company on the second line.

 

 function tep_address_format($address_format_id, $address, $html, $boln, $eoln) {
   $address_format_query = tep_db_query("select address_format as format from " . TABLE_ADDRESS_FORMAT . " where address_format_id = '" . (int)$address_format_id . "'");
   $address_format = tep_db_fetch_array($address_format_query);

   $company = tep_output_string_protected($address['company']);
   if (isset($address['firstname']) && tep_not_null($address['firstname'])) {
     $firstname = tep_output_string_protected($address['firstname']);
     $lastname = tep_output_string_protected($address['lastname']);
   } elseif (isset($address['name']) && tep_not_null($address['name'])) {
     $firstname = tep_output_string_protected($address['name']);
     $lastname = '';
   } else {
     $firstname = '';
     $lastname = '';
   }
   $street = tep_output_string_protected($address['street_address']);
// Second Address Field mod:
   $street_2 = tep_output_string_protected($address['street_address_2']);
// :Second Address Field mod
   $suburb = tep_output_string_protected($address['suburb']);
   $city = tep_output_string_protected($address['city']);
   $state = tep_output_string_protected($address['state']);
   if (isset($address['country_id']) && tep_not_null($address['country_id'])) {
     $country = tep_get_country_name($address['country_id']);

     if (isset($address['zone_id']) && tep_not_null($address['zone_id'])) {
       $state = tep_get_zone_code($address['country_id'], $address['zone_id'], $state);
     }
   } elseif (isset($address['country']) && tep_not_null($address['country'])) {
     $country = tep_output_string_protected($address['country']);
   } else {
     $country = '';
   }
   $postcode = tep_output_string_protected($address['postcode']);
   $zip = $postcode;

   if ($html) {
// HTML Mode
     $HR = '<hr>';
     $hr = '<hr>';
     if ( ($boln == '') && ($eoln == "\n") ) { // Values not specified, use rational defaults
       $CR = '<br>';
       $cr = '<br>';
       $eoln = $cr;
     } else { // Use values supplied
       $CR = $eoln . $boln;
       $cr = $CR;
     }
   } else {
// Text Mode
     $CR = $eoln;
     $cr = $CR;
     $HR = '----------------------------------------';
     $hr = '----------------------------------------';
   }

   $statecomma = '';
   $streets = $street;
// Second Address Field mod:
   if ($street_2 != '') $streets = $street . $cr . $street_2;
// :Second Address Field mod
   if ($suburb != '') $streets = $street . $cr . $suburb;
   if ($country == '') $country = tep_output_string_protected($address['country']);
   if ($state != '') $statecomma = $state . ', ';

   $fmt = $address_format['format'];
   eval("\$address = \"$fmt\";");

   if ( (ACCOUNT_COMPANY == 'true') && (tep_not_null($company)) ) {
     $address = $company . $cr . $address;
   }

   return $address;
 }

 

for further reference, address format calls a table that gives out something like this

 

$firstname $lastname$cr$streets$cr$city, $postcode$cr$statecomma$country

 

couldn't i just tell it if account company = true, use a format that is like this

 

$firstname $lastname$cr$company$cr$streets$cr$city, $postcode$cr$statecomma$country

 

 

and just add that as another entry in the table?

 

or, just write that out instead of...

 

if ( (ACCOUNT_COMPANY == 'true') && (tep_not_null($company)) ) {

$address = $company . $cr . $address;

}

 

do it where it says

 

$address =

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...