Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

customize welcome message with gender...


Guest

Recommended Posts

Hello everybody..... (i have allready post the same message on ian's forum, so sorry if you've allready read it....)

 

so in fact i would like to customize the welcome message with something like "welcome Mr X" if the gender of the customer is male , "welcome Mrs X" if the gender is female and welcome guest if there is no login customer....

 

So i tried to change tep_customer_greeting() to suit my needs but in fact i don't know how to request the gender from the database before testing the value of $gender....:-( because with the delaration i made "$gender" is always empty )

function tep_customer_greeting() {

global $HTTP_COOKIE_VARS, $customer_id, $customer_first_name , $customer_gender;

 

if ($HTTP_COOKIE_VARS['first_name']) {

$first_name = stripslashes($HTTP_COOKIE_VARS['first_name']);

} elseif ($customer_first_name) {

$first_name = $customer_first_name;

}

 

if ($first_name) {

$gender = $customer_gender;

if ($gender == 'm') {

$greeting_string = sprintf(TEXT_GREETING_PERSONAL_MALE, $first_name, tep_href_link(FILENAME_PRODUCTS_NEW, '', 'NONSSL'));

}

else {

$greeting_string = sprintf(TEXT_GREETING_GUEST_FEMALE, tep_href_link(FILENAME_LOGIN, '', 'SSL'), tep_href_link(FILENAME_CREATE_ACCOUNT, '', 'SSL'));

}

 

if (!$customer_id) {

$greeting_string .= '<br>' . sprintf(TEXT_GREETING_PERSONAL_RELOGON, $first_name, tep_href_link(FILENAME_LOGIN, '', 'SSL'));

}

} else {

$greeting_string = sprintf(TEXT_GREETING_GUEST, tep_href_link(FILENAME_LOGIN, '', 'SSL'), tep_href_link(FILENAME_CREATE_ACCOUNT, '', 'SSL'));

}

 

return $greeting_string;

}

 

is there someone who has ever made changes like this ? or someone who could teach me how to make the correct DB request to get the value of the customer's gender ? :-)

 

Thanks in advance for your time and energy guys.... one more time !!

 

maya

Link to comment
Share on other sites

:D what a good news !!!

 

............what "PM" means ? sorry i'm french and my understanding of your so nice language is not perfect :oops:

 

see you Waza

Link to comment
Share on other sites

so....i try to request the database into the function......

this is what i try:

 

if ($first_name) {

            $db = mysql_connect('localhost','****','*******') or die ("error db");

            mysql_select_db('****',$db) or die ("error db");

 

            $toto = mysql_query("SELECT customers_gender from customers where customers_id = $custumer_id ");

            if ($toto == 'm') {

            $greeting_string = sprintf(TEXT_GREETING_PERSONAL MALE, $first_name, tep_href_link(FILENAME_PRODUCTS_NEW, '', 'NONSSL'));

            }

            else {

            $greeting_string = sprintf(TEXT_GREETING_GUEST_FEMALE, tep_href_link(FILENAME_LOGIN, '', 'SSL'), tep_href_link(FILENAME_CREATE_ACCOUNT, '', 'SSL'));

            }

 

so the entire function will look like this

 

// Return a customer greeting

function tep_customer_greeting() {

   global $HTTP_COOKIE_VARS, $customer_id, $customer_first_name , $customer_gender;

   $gender = tep_db_prepare_input($HTTP_POST_VARS['gender']);

 

   if ($HTTP_COOKIE_VARS['first_name']) {

     $first_name = stripslashes($HTTP_COOKIE_VARS['first_name']);

   } elseif ($customer_first_name) {

     $first_name = $customer_first_name;

   }

 

   if ($first_name) {

            $db = mysql_connect('localhost','*****','*********') or die ("error db");

            mysql_select_db('*****',$db) or die ("error db");

 

            $toto = mysql_query("SELECT customers_gender from customers where customers_id = 2 ");

            if ($toto == 'm') {

            $greeting_string = sprintf(TEXT_GREETING_PERSONAL, $first_name, tep_href_link(FILENAME_PRODUCTS_NEW, '', 'NONSSL'));

            }

            else {

            $greeting_string = sprintf(TEXT_GREETING_GUEST_FEMELE, tep_href_link(FILENAME_LOGIN, '', 'SSL'), tep_href_link(FILENAME_CREATE_ACCOUNT, '', 'SSL'));

            }

 

if (!$customer_id) {

       $greeting_string .= '<br>' . sprintf(TEXT_GREETING_PERSONAL_RELOGON, $first_name, tep_href_link(FILENAME_LOGIN, '', 'SSL'));

     }

   } else {

     $greeting_string = sprintf(TEXT_GREETING_GUEST, tep_href_link(FILENAME_LOGIN, '', 'SSL'), tep_href_link(FILENAME_CREATE_ACCOUNT, '', 'SSL'));

   }

 

   return $greeting_string;

 }

 

but it's not the way :oops:

anyone gets an idea to make it works ?

 

thankkkkkkkkkkkkkkkkk you dears 8)

Link to comment
Share on other sites

Just as a warning, not all females go by 'Mrs'. And some of them get downright pissed off when they get called it. There are alot of other titles for females, such as 'Miss', 'Ms', well I have run out but there are more. Also note that some people are Doctors (Dr) and get offended when called anything else. Just a warning, that's all.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...