macel Posted April 10, 2013 Share Posted April 10, 2013 Hi, I'd like to remove name and last name from billing address if the customer identifies himself as a company (they choose between customer/company while creating a new account). Currently my billing address looks like this: Company name VAT no Name Last name Address Address I want to remove the name as it confuses my clients (they think I will include the person's name in an invoice). I can't remove name fields from create account as I need to know who placed an order but I don't want it to appear in the billing part... just the company name... Help anyone? Link to comment Share on other sites More sharing options...
Bob Terveuren Posted April 10, 2013 Share Posted April 10, 2013 Hi here's a quick 'hack' that will modify the address for you - there's probably more elegant and involved ways of doing it but try this ....... The address display in the checkout are partly controlled by a function in the file inlcudes/functions/general.php - if you look in there you'll see tep_address_label is one of these - clone this to tep_address_label_billing by adding this code into the general.php file ///////////////////////////////////// new function ////////////////////////// function tep_address_label_billing($customers_id, $address_id = 1, $html = false, $boln = '', $eoln = "\n") { if (is_array($address_id) && !empty($address_id)) { return tep_address_format($address_id['address_format_id'], $address_id, $html, $boln, $eoln); } $address_query = tep_db_query("select entry_firstname as firstname, entry_lastname as lastname, entry_company as company, entry_street_address as street_address, entry_suburb as suburb, entry_city as city, entry_postcode as postcode, entry_state as state, entry_zone_id as zone_id, entry_country_id as country_id from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$customers_id . "' and address_book_id = '" . (int)$address_id . "'"); $address = tep_db_fetch_array($address_query); if(tep_not_null($address['company'])){//some data in the company field $address['firstname']=$address['company']; unset($address['lastname']); unset($address['company']); } $format_id = tep_get_address_format_id($address['country_id']); return tep_address_format($format_id, $address, $html, $boln, $eoln); } ////////////////////////////////////////////////////////////////////////////// Basically all this does is see if there's data in the company field and, if any, it exchanges that data for the original firstname then deletes any lastname and the original company data. Now you need to sort through your catalog and find the places where you want the different info to appear - change the call to tep_address_label to _billing e.g. checkout_payment around line 150 <?php echo tep_address_label($customer_id, $billto, true, ' ', '<br />'); ?> becomes <?php echo tep_address_label_billing($customer_id, $billto, true, ' ', '<br />'); ?> Once you've done this you'll see that the billing address in checkout_confirmation still has the name fields - so to change that one you have to edit the file includes/classes/order.php with something similar: If you look through that file at around line 250 you'll see where it sets up $this->billing as an array $this->billing = array('firstname' => $billing_address['entry_firstname'], 'lastname' => $billing_address['entry_lastname'], ............ Add in above that : //////////////////////////////// new code //////////////////// if(tep_not_null($billing_address['entry_company'])){ $billing_address['entry_firstname']=$billing_address['entry_company']; unset($billing_address['entry_company']); unset($billing_address['entry_lastname']); } /////////////////////////////////////////////////////////// $this->billing = array('firstname' => $billing_address['entry_firstname'], 'lastname' => $billing_address['entry_lastname'], ......................... That will do the same thing - just swap the company field into firstname and lose the lastname - the order will get saved with the details like that and you should see the admin invoice/packing slip etc matching Link to comment Share on other sites More sharing options...
macel Posted April 12, 2013 Author Share Posted April 12, 2013 Thank you, it works perfectly! I'd never figure that out by myself. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.