burtoni Posted September 20, 2005 Share Posted September 20, 2005 On the log-in page, the welcome message comes up: Welcome back Robert! How and where can I change the configuration (class: GreetUser?) so that the Surname (last name) is shown instead of the first name? Is it in the 'define (TEXT_GREETING_PERSONAL)' where i have to change the code to the first name? I found out from the create_account.php that EMAIL_GREET_MR gives the Surname of the person: define('EMAIL_GREET_MR', 'Bonjour M. %s,' . "\n\n"); Now how do I implementate that into my code in the english.php file, so that the last name is given? (about line 286) define('TEXT_GREETING_PERSONAL', 'Welcome <span class="greetUser">%s!</span> Link to comment Share on other sites More sharing options...
FalseDawn Posted September 20, 2005 Share Posted September 20, 2005 You're looking in the wrong place, the "%s" in the EMAIL_GREET_MR constant is just a placeholder. You need to find the sprintf command that replaces this placeholder with the specified string (the surname in this case), and change that to use whatever string you want. Link to comment Share on other sites More sharing options...
burtoni Posted September 21, 2005 Author Share Posted September 21, 2005 Thanks FalseDawn.... Thanks for bringing me on the right track. I suppose you mean the following section in the general.php file: // Return a customer greeting ?function tep_customer_greeting() { ? ?global $customer_id, $customer_first_name; ? ?if (tep_session_is_registered('customer_first_name') && tep_session_is_registered('customer_id')) { ? ? ?$greeting_string = sprintf(TEXT_GREETING_PERSONAL, tep_output_string_protected($customer_first_name), tep_href_link(FILENAME_PRODUCTS_NEW)); ? ?} else { ? ? ?$greeting_string = sprintf(TEXT_GREETING_GUEST, tep_href_link(FILENAME_LOGIN, '', 'SSL'), tep_href_link(FILENAME_CREATE_ACCOUNT, '', 'SSL')); ? ?} ? ?return $greeting_string; ?} I personaly would just change all "customer_first_name" to "customer_last_name", but I dont know if this is sufficient. Before I get in a right mess, could you please include the adjusted code for me? (might be of some help for other users too!) Probably you will be telling me to change the PERSONAL part to something else?: sprintf(TEXT_GREETING_PERSONAL p.s. The title 'Mr./Mrs.' would have to be included between the "Dear & LASTNAME" Link to comment Share on other sites More sharing options...
FalseDawn Posted September 21, 2005 Share Posted September 21, 2005 No, that wouldn't work - you can't just change variables and expect them to "magically" contain the data relating to their name. $customer_first_name is registered in the session when a customer logs on (hint - look in the login.php file) Declaring it as a global makes it available in this function. You can either change the query in login.php to pull the last name (and gender) from the customers table and store this info in the session, then declare these new variables as globals in the function, OR you can use the stored customer_id to fire off another simple query to retrieve the last name and gender in this function. Personally, I'd go for the first as it doesn't involve any extra querying. Link to comment Share on other sites More sharing options...
burtoni Posted September 21, 2005 Author Share Posted September 21, 2005 I cant believe that nobody has come up with a contribution or solution to this problem already in this forum. In Switzerland, as I am sure is in Germany and Austria too, they always greet customers by their last name. Anyway, seing as I have no clue nor experience, I am quitting on this one. I'll just have to change the greeting to a standard 'Dear member' or 'Dear customer', if noone can tell me where a contribution or a solution to my answer is. :( Link to comment Share on other sites More sharing options...
burtoni Posted September 22, 2005 Author Share Posted September 22, 2005 OK I have updated the fields in the login.php but now I am meant to do the following: Then in your function, declare $customer_last_name and $customer_gender as global and they will be available to use. Can someone briefly tell me in which file I am meant to do this? The only function in login.php is line 89 function session_win() { and in the languages/login.php there is no funtion syntax. Link to comment Share on other sites More sharing options...
kalle Posted September 22, 2005 Share Posted September 22, 2005 OK I have updated the fields in the login.php but now I am meant to do the following:Can someone briefly tell me in which file I am meant to do this? The only function in login.php is line 89 function session_win() { and in the languages/login.php there is no funtion syntax. <{POST_SNAPBACK}> The solution is pretty trivial, you just need to edit the query in login.php, store the results in a variable and then refer to this variable in includes/functions/general.php. Cheers, Kalle! Link to comment Share on other sites More sharing options...
burtoni Posted September 23, 2005 Author Share Posted September 23, 2005 It may be trivial for you, but not for a novice! Here is the section in my general.php which I suppose is the only target: // Return a customer greeting ?function tep_customer_greeting() { ? ?global $customer_id, $customer_first_name; ? ?if (tep_session_is_registered('customer_first_name') && tep_session_is_registered('customer_id')) { ? ? ?$greeting_string = sprintf(TEXT_GREETING_PERSONAL, tep_output_string_protected($customer_first_name), tep_href_link(FILENAME_PRODUCTS_NEW)); ? ?} else { ? ? ?$greeting_string = sprintf(TEXT_GREETING_GUEST, tep_href_link(FILENAME_LOGIN, '', 'SSL'), tep_href_link(FILENAME_CREATE_ACCOUNT, '', 'SSL')); ? ?} ? ?return $greeting_string; ?} I have changed the first three lines to this; is that sufficient?: ?function tep_customer_greeting() { ? ?global $customer_id, $customer_gender, $customer_last_name; ? ?if (tep_session_is_registered('customer_last_name') && tep_session_is_registered('customer_id')) { Do I have to change all customer_first_name to customer_last_name? Do I not have to insert any other lines for the gender? Link to comment Share on other sites More sharing options...
Guest Posted September 23, 2005 Share Posted September 23, 2005 This is the code you need in login.php (compare it with the original): // Check if email exists ? ?$check_customer_query = tep_db_query("select customers_id, customers_firstname, customers_lastname, customers_password, customers_email_address, customers_default_address_id from " . TABLE_CUSTOMERS . " where customers_email_address = '" . tep_db_input($email_address) . "'"); ? ?if (!tep_db_num_rows($check_customer_query)) { ? ? ?$error = true; ? ?} else { ? ? ?$check_customer = tep_db_fetch_array($check_customer_query); // Check that password is good ? ? ?if (!tep_validate_password($password, $check_customer['customers_password'])) { ? ? ? ?$error = true; ? ? ?} else { ? ? ? ?if (SESSION_RECREATE == 'True') { ? ? ? ? ?tep_session_recreate(); ? ? ? ?} ? ? ? ?$check_country_query = tep_db_query("select entry_country_id, entry_zone_id from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$check_customer['customers_id'] . "' and address_book_id = '" . (int)$check_customer['customers_default_address_id'] . "'"); ? ? ? ?$check_country = tep_db_fetch_array($check_country_query); ? ? ? ?$customer_id = $check_customer['customers_id']; ? ? ? ?$customer_default_address_id = $check_customer['customers_default_address_id']; ? ? ? ?$customer_first_name = $check_customer['customers_firstname']; ? ? ? ?$customer_last_name = $check_customer['customers_lastname']; ? ? ? ?$customer_country_id = $check_country['entry_country_id']; ? ? ? ?$customer_zone_id = $check_country['entry_zone_id']; ? ? ? ?$customer_email = $HTTP_POST_VARS['email_address']; ? ? ? ?tep_session_register('customer_id'); ? ? ? ?tep_session_register('customer_default_address_id'); ? ? ? ?tep_session_register('customer_first_name'); ? ? ? ?tep_session_register('customer_last_name'); ? ? ? ?tep_session_register('customer_country_id'); ? ? ? ?tep_session_register('customer_zone_id'); ? ? ? ?tep_session_register('customer_email'); and in /includes/functions/general.php: // Return a customer greeting ?function tep_customer_greeting() { ? ?global $customer_id, $customer_last_name; ? ?if (tep_session_is_registered('customer_last_name') && tep_session_is_registered('customer_id')) { ? ? ?$greeting_string = sprintf(TEXT_GREETING_PERSONAL, tep_output_string_protected($customer_last_name), tep_href_link(FILENAME_PRODUCTS_NEW)); ? ?} else { ? ? ?$greeting_string = sprintf(TEXT_GREETING_GUEST, tep_href_link(FILENAME_LOGIN, '', 'SSL'), tep_href_link(FILENAME_CREATE_ACCOUNT, '', 'SSL')); ? ?} ? ?return $greeting_string; ?} :D Matti Link to comment Share on other sites More sharing options...
burtoni Posted September 23, 2005 Author Share Posted September 23, 2005 Hi Johnson It seems to be the same script as above, I overpasted the code and uploaded both files, but still only the LASTNAME shows without the GENDER (Dear Burton instead of Mr. Burton) Do you know where the bug is? Link to comment Share on other sites More sharing options...
Guest Posted September 23, 2005 Share Posted September 23, 2005 I didn't read the gender part :blink: Busy man, sorry - if nobody else replies, I shall tomorrow - its much the same as what has already been done - you need an if/else statement for m and f in login.php and to register the result Matti Link to comment Share on other sites More sharing options...
burtoni Posted September 23, 2005 Author Share Posted September 23, 2005 OK, Kalle or FalseDawn might reply in the meantime. Unless anyone else knows the solution, I would be grateful. Just wondering: wouldnt it be useful to make this into a contribution? Theres quite a bit of code there, and in Europe many countries greet their customers by their Surnames... Anyway, I have to go Online now. Customers will just be greeted by their Name. I'll then update the store next Monday. Many thanks in advance. Link to comment Share on other sites More sharing options...
Guest Posted September 23, 2005 Share Posted September 23, 2005 You need to change 5 files to have this. account_edit.php address_book_process.php create_account.php login.php functions\general.php because the customer can change the gender or last name in different ways. You will also need to check if ACCOUNT_GENDER is enabled before displaying the gender field. Some of these files do sql queries so you would need to modify them to include the customers_gender column See how the code does it for the first name and replicate it for the gender. The only difference is to set the gender string (something like $customers_gender) to a string from the char that currently is stored. Like: $customers_gender = ($gender == 'm')?'Mr':'Mrs'; In general.php add the $customers_gender global which will now be valid (once you mod the other 4 files) and append the gender with the sprintf. Link to comment Share on other sites More sharing options...
ianric Posted August 10, 2006 Share Posted August 10, 2006 Hi I wanted something similar but with welcome first_name last_name, may even add Mr, Mrs etc. With help from this post I figured it out and I'll post the code when I have remembered what I have done to what files. Ian Link to comment Share on other sites More sharing options...
gurmeden Posted January 10, 2008 Share Posted January 10, 2008 Well, I want to thank to enigma1, Johnson and burtoni for this discussion. The information was really useful! :rolleyes: Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.