PDA

View Full Version : [Core Hack] Show customer group name to customer



Martin Heidegger
11-19-2011, 03:58 AM
Hi!
I have two customer groups and I would like to show the customer when logged in her/his customer group name. Perhaps after the greating: "Welcome back xxxx. You are registered as Privat cutomer" or "Welcome back xxxx. You are registered as Business cutomer". Ny suggestions?

pgmarshall
11-19-2011, 05:15 AM
Open catalog/includes/functions/information.php and change the function at the bottom to this:



// Return a customer greeting
function tep_information_customer_greeting() {
global $customer_id, $customer_first_name;

$sppc_group_query_raw = tep_db_query("select customers_group_name from " . TABLE_CUSTOMERS . " where customers_id = " . $customer_id);
while ($sppc_group_query = tep_db_fetch_array($sppc_group_query_raw)) {
$sppc_group_name = $sppc_group_query['customers_group_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_output_string_protected($sppc_group_name), tep_href_link(FILENAME_DEFAULT, "new_products=1"));
} else {
$greeting_string = sprintf(TEXT_GREETING_GUEST, tep_href_link(FILENAME_LOGIN, '', 'SSL'), '', tep_href_link(FILENAME_CREATE_ACCOUNT, 'SSL'));
}

return $greeting_string;
}


Then simply open your admin panel -> Configuration -> Templates -> Welcome Message -> Edit 'Greeting to known user' -> Switch to source mode in CKEditor

Then enter:


<p>Welcome back <span class="greetUser">%s!</span> You are logged in as a %s customer. Would you like to see which <a href="%s"><u>new products</u></a> are available to purchase?</p>


Remember you will need to do this for each language.

Job done.

Regards.

Martin Heidegger
11-19-2011, 06:54 AM
Thank you very much pgmarshall. I had to do the second change on the language file core.php and not on the admin. That because I dindn't find any options when coming to admin panel -> Configuration -> Templates -> Welcome Message. I have now what I wanted and that very quickly. Thanks for that.

Martin Heidegger
11-19-2011, 07:09 AM
There is a problem when customer is not logged in. I get this error message:

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

select customers_group_name from customers where customers_id =

Martin Heidegger
11-19-2011, 07:23 AM
I have changed the code a little and voila:

// Return a customer greeting
function tep_information_customer_greeting() {
global $customer_id, $customer_first_name;

$sppc_group_query_raw = tep_db_query("select customers_group_name from " . TABLE_CUSTOMERS . " where customers_id = '" . $customer_id . "'");
while ($sppc_group_query = tep_db_fetch_array($sppc_group_query_raw)) {
$sppc_group_name = $sppc_group_query['customers_group_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_output_string_protected($sppc_group_name), tep_href_link(FILENAME_DEFAULT, "new_products=1"));
} else {
$greeting_string = sprintf(TEXT_GREETING_GUEST, tep_href_link(FILENAME_LOGIN, '', 'SSL'), '', tep_href_link(FILENAME_CREATE_ACCOUNT, 'SSL'));
}

return $greeting_string;
}

pgmarshall
11-19-2011, 12:52 PM
No problem. Glad you got it working how you wanted.

Also thanks for contributing to the support of osCmax.

Regards.