I am looking for a way to display which user group a customer belongs to. I need this to show up in two locations.
One is the customer list page. I have already added a column and am attempting to insert the user group variable. Unfortunately nothing I have tried works.
Also i need it to display under customer information in the abandoned carts information.
I have tried several variations, none of which have worked.
{$user_data.usergroup}
{$usergroup.usergroup}
{$user_data.usergroups}
{$user_data.usergroup_active}
{$usergroups.usergroup}
{$usergroup.usergroup_id}
just to name a few. I would appreciate some guidance here!
Thank you in advance.
SDAD
December 16, 2015, 12:00am
2
For abandonded carts:
Add the following code:
foreach ($carts_list as $key => $cart_data) {
$carts_list[$key]['usergroups'] = '';
if (!empty($cart_data['user_data']) && !empty($cart_data['user_data']['usergroups'])) {
$usergroups = db_get_fields("SELECT usergroup FROM ?:usergroup_descriptions WHERE usergroup_id IN (?a) AND lang_code = ?s", array_keys($cart_data['user_data']['usergroups']), DESCR_SL);
$carts_list[$key]['usergroups'] = implode(', ', $usergroups);
}
}
just above the following line:
Tygh::$app['view']->assign('carts_list', $carts_list);
in the app/controllers/backend/cart.php .
Then replace the following line:
{if $customer.user_data.email}{if $customer.firstname || $customer.lastname}{$customer.lastname} {$customer.firstname}{else}{$customer.user_data.email}{/if} {else}{__("unregistered_customer")}{/if}
with this one:
{if $customer.user_data.email}{if $customer.firstname || $customer.lastname}{$customer.lastname} {$customer.firstname}{else}{$customer.user_data.email}{/if} {$customer.usergroups nofilter}{else}{__("unregistered_customer")}{/if}
in the design/backend/templates/views/cart/cart_list.tpl
SDAD
December 16, 2015, 12:00am
3
For Customers page in the administrator area, add the following lines:
foreach ($users as $key => $user) {
$user_usergroups = array_keys(fn_get_user_usergroups($user['user_id']));
if (!empty($user_usergroups)) {
$usergroups = db_get_fields("SELECT usergroup FROM ?:usergroup_descriptions WHERE usergroup_id IN (?a) AND lang_code = ?s", $user_usergroups, DESCR_SL);
} else {
$usergroups = array();
}
$users[$key]['usergroups'] = implode(', ', $usergroups);
}
just below the following line:
list($users, $search) = fn_get_users($_REQUEST, $auth, Registry::get('settings.Appearance.admin_elements_per_page'));
in the app/controllers/backend/profiles.php
Then replace the following line:
{if $user.firstname || $user.lastname}{$user.lastname} {$user.firstname} {else}-{/if}{if $user.company_id}{include file="views/companies/components/company_name.tpl" object=$user}{/if}
with the following one:
{if $user.firstname || $user.lastname}{$user.lastname} {$user.firstname} {else}-{/if} {$user.usergroups nofilter}{if $user.company_id}{include file="views/companies/components/company_name.tpl" object=$user}{/if}
in the design/backend/templates/views/profiles/manage.tpl
And do not forget to clear clear the cache before checking the changes.
Worked perfectly! Thank you very much!