Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

How to display the company name in the Invoices?


CharisMac

Recommended Posts

I've been banging my head against a wall for the last couple of days. Not just any wall, but a nice thick concrete one. :?

 

I have an older build of OSC, I'm not sure what version (any ideas where to get that?). But, so far everything is working well with one exception. I have been unable to figure out how to get the Company Name to display in the Invoice or Packing Slip pages.

 

We are requiring that users enter it, it shows up in their Customer information (from the Address Book table in the entry_company field) but for the life of me I cannot get this to display in the invoice or packing slip.

 

This has caused a few orders to get returned to us because the UPS driver didn't know what company to deliver to at that specific address. Please help, I've searched this board for days and there seems to be several threads about this but lack the info I am seeking. :cry:

Link to comment
Share on other sites

Take a look in your admin/invoice.php and admin/packingslip.php files and find the line that generates the address.

 

The line should be a call to the tep_address_format function.

 

If it is, then take a look in your admin/includes/functions/general.php file for the tep_address_format definition and verify that the company is a part of the address build.

"Great spirits have always found violent opposition from mediocre minds. The latter cannot understand it when a man does not thoughtlessly submit to hereditary prejudices but honestly and courageously uses his intelligence." - A. Einstein

Link to comment
Share on other sites

It's not in there. Would adding a line like this help?

$company = addslashes($address['company']);

 

This is what is there now:

$firstname = addslashes($address['firstname']);

   $lastname = addslashes($address['lastname']);

   $street = addslashes($address['street_address']);

   $suburb = addslashes($address['suburb']);

   $city = addslashes($address['city']);

   $state = addslashes($address['state']);

   $country_id = $address['country_id'];

   $zone_id = $address['zone_id'];

   $postcode = addslashes($address['postcode']);

   $zip = $postcode;

   $country = tep_get_country_name($country_id);

   $state = tep_get_zone_code($country_id, $zone_id, $state);

Link to comment
Share on other sites

Yes, that would do nicely. :)

 

Be sure to verify that the company is one of the fields listed in the sql select a few statements above the code that you quoted.

 

You will also want to ensure that the company field is included in the statements after the code quote when the actual address string is built.

"Great spirits have always found violent opposition from mediocre minds. The latter cannot understand it when a man does not thoughtlessly submit to hereditary prejudices but honestly and courageously uses his intelligence." - A. Einstein

Link to comment
Share on other sites

Hmm... I don't see any selects in that code that call out stuff like address or anything. It seems like this is something that everyone expects to work but some code got left out. There is however code that calls on $country to attempt to prepare the address...

 

I assume the fact that the address_formats do not have $company listed could also be an issue, yes?

 

So change:

$firstname $lastname$cr$streets$cr$city, $state ? ?$postcode$cr$country

to:

$firstname $lastname$cr$company$cr$streets$cr$city, $state ? ?$postcode$cr$country

?

And that would have to be for all country codes as well I presume?

Link to comment
Share on other sites

Ok, there seems to be two tables in the DB that contain address information. The customer.php file pulls info from the address_book table, which, from what I can tell, seems to be a repository for data which is entered and editable by the user. **This table contains Company names**

 

The other table, customers, seems to be a table which transfers the address information from the address_book table at the time of the order. The invoice.php and packingslip.php files seem to pull the data it needs out of this table. I assume that it does this so edits in the address_book table do not changes existing orders. **This table does not contain any Company names**

 

Let me know if I'm way off base here, but, I presume that part of the issue has to do with the fact that the customers table contains no company names whatsoever (becasue it is not being linked for some reason). Even so, if I manually enter a company name it does not get added to the invoice. :?

Link to comment
Share on other sites

The address information that is displayed on the invoice and packingslip pages is actually from the orders table.

 

At the time the order is placed, all of the relevant information is written to the orders table. That way the user can add/remove addresses and/or modify their personal information without affecting previous orders.

 

The entire function should look like this:

  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 = '" . $address_format_id . "'");

   $address_format = tep_db_fetch_array($address_format_query);



   $company = addslashes($address['company']);

   $firstname = addslashes($address['firstname']);

   $lastname = addslashes($address['lastname']);

   $street = addslashes($address['street_address']);

   $suburb = addslashes($address['suburb']);

   $city = addslashes($address['city']);

   $state = addslashes($address['state']);

   $country_id = $address['country_id'];

   $zone_id = $address['zone_id'];

   $postcode = addslashes($address['postcode']);

   $zip = $postcode;

   $country = tep_get_country_name($country_id);

   $state = tep_get_zone_code($country_id, $zone_id, $state);



   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;

   if ($suburb != '') $streets = $street . $cr . $suburb;

   if ($firstname == '') $firstname = addslashes($address['name']);

   if ($country == '') $country = addslashes($address['country']);

   if ($state != '') $statecomma = $state . ', ';



   $fmt = $address_format['format'];

   eval("$address = "$fmt";");

   $address = stripslashes($address);



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

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

   }



   return $boln . $address . $eoln;

 }

assuming that you have the MileStone2 release of osCommerce.

 

Please let me know if you are using a different release.

"Great spirits have always found violent opposition from mediocre minds. The latter cannot understand it when a man does not thoughtlessly submit to hereditary prejudices but honestly and courageously uses his intelligence." - A. Einstein

Link to comment
Share on other sites

Actually, as I said, it's an older version. I can't find a version anywhere (can you tell me where I can find the build version?) but the build was from roughly Sept. 2002.

 

Also, we are wondering, with the addition of several mods how easy is it to update becasue it appears that this is not a problem in the MileStone2 release.

Link to comment
Share on other sites

OK, mine doesn't have this code:

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

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

? ? }

 

 

When I add it I get these errors:

Parse error: parse error, unexpected T_STRING in C:InetPubwwwrootadminincludesfunctionsgeneral.php on line 394

Fatal error: Call to undefined function: tep_address_format() in C:InetPubwwwrootadminorders.php on line 130

Link to comment
Share on other sites

:? How did I know you were going to say that?

 

OK, next question, how easy (or how difficult) is it to go from a build from Sept of last year to MS2? It's obvious I need to explore this route.

 

Is upgrading osC similar to that of phpbb? Or more complicated?

Link to comment
Share on other sites

The upgradeability of your installation to MS2 is highly dependent upon the modifications that you have made to your current store.

 

If it is a stock store with nothing but some color changes in the stylesheet, then the upgrade will be extremely easy.

 

If you have 20 contributions as well as 4 custom developed solutions, your upgrade will be a nightmare.

 

Does that help (information wise as I am sure you really did not want to hear the word nightmare :P )?

"Great spirits have always found violent opposition from mediocre minds. The latter cannot understand it when a man does not thoughtlessly submit to hereditary prejudices but honestly and courageously uses his intelligence." - A. Einstein

Link to comment
Share on other sites

Can you point me (and others) to a place with tips on how to make this "easy" upgrade? (in other words, how to import the products I have put in the old version into the newer version after I have installed it). The 2.1 installation that was provided by my new hosting service is not working correctly. Do I need to have other specialized software (or does the hosting company?) to make the newer version work? I've read through so many 'instructions' that just say "import your products and you're ready to go" or similar, as if one should have been born with an understanding of how to do so.

 

Any and all help is much appreciated. Julie

Link to comment
Share on other sites

Julie,

 

If you are working with a stock The Exchange Project (what osCommerce was named at that time) v2.1 installation, then you are in luck.

 

When you run the install script for the osCommerce MS2 release, select the Upgrade option and this will upgrade your database (along with the files) and that should be all there is to it (other than completing the information requested by the install script).

 

If you are running a version of osCommerce that is 2.2 but prior to MS2, then you can export your catalog and user information and import that information into the MS2 database.

 

I believe (but do not know for sure) that there is an upgrade script that will upgrade a 2.2-but-prior-to-MS2-database to the MS2 structure.

 

I know the above is about as clear as mud, so please let me know if you have any questions or if you are in a situation that I did not touch upon in the above.

"Great spirits have always found violent opposition from mediocre minds. The latter cannot understand it when a man does not thoughtlessly submit to hereditary prejudices but honestly and courageously uses his intelligence." - A. Einstein

Link to comment
Share on other sites

My pages all say The Exchange Project in big wavy letters at the top! Thank you, Daemon! I was feeling pretty 'down', but now will tackle the change-over with hopeful enthusiasm! And won't hesitate to ask if I go astray again! Julie :)

Link to comment
Share on other sites

Glad to help Julie and definitely do not be afraid to ask questions.

 

Be sure to make a backup of your current site (including the database) so that you have something to revert back to in case something goes wrong. ;)

 

I am a firm believer in having backup regardless of how sure something is. You just never know when the power might go out. ;)

"Great spirits have always found violent opposition from mediocre minds. The latter cannot understand it when a man does not thoughtlessly submit to hereditary prejudices but honestly and courageously uses his intelligence." - A. Einstein

Link to comment
Share on other sites

The upgradeability of your installation to MS2 is highly dependent upon the modifications that you have made to your current store.

 

If it is a stock store with nothing but some color changes in the stylesheet, then the upgrade will be extremely easy.

 

If you have 20 contributions as well as 4 custom developed solutions, your upgrade will be a nightmare.

 

Does that help (information wise as I am sure you really did not want to hear the word nightmare :P )?

Well, "nightmare," wasn't exaclty what I wanted to hear. We've added a couple contributions as well as minor customization throughout the store. It's sounding more and more like I need to bring a new store up from scratch. :(

 

Where is the opton to export the customers data so it can be imported? I haven't seen that that I can recall.

Link to comment
Share on other sites

Well, "nightmare," wasn't exaclty what I wanted to hear.  We've added a couple contributions as well as minor customization throughout the store.  It's sounding more and more like I need to bring a new store up from scratch.  :(

I does not sound like you will have it too bad.

 

Installing a new MS2 store will take less than 15 minutes.

 

It will probably take a couple of hours to put in the contributions (assuming there are MS2 ports for them available).

 

I cannot comment on whether you can carryover the custom development since I do not have any information on it.

 

Overall, it may take you a few hours but you should be good to go then. That is not that bad. :)

 

Where is the opton to export the customers data so it can be imported?  I haven't seen that that I can recall.

That is not available from osC but you can do it from within PHPMyAdmin. Select your database, select Export, select the address_book, customers, manufacturers, orders, and products tables, select data only, do not drop table but do complete inserts (not extended), and download the information into a file.

 

Then import the information into you new MS2 database and you should then only have to go through the configuration of your new store. All of your customers with their previous orders should be available in your new store.

 

Let me know if you have any questions regarding the above or run into any troubles.

"Great spirits have always found violent opposition from mediocre minds. The latter cannot understand it when a man does not thoughtlessly submit to hereditary prejudices but honestly and courageously uses his intelligence." - A. Einstein

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...