A customer can be a member of one or multiple groups, which can be displayed on a page. Below are examples of Smarty code that display the group IDs or names that the customer is a member of:
A customer can be a member of one or multiple groups, which can be displayed on a page. Below are examples of Smarty code that display the group IDs or names that the customer is a member of:
group_ids
{{$customer.group_ids}}
Output:
Array
(
[0] => 3
[1] => 6
[2] => 7
)
group_names
{{$customer.group_names}}
Output:
Array
(
[0] => Group 1
[1] => Group 3
[2] => Group 4
)
Foreach loop
{{foreach $customer.group_names as $groupname}}
{{$groupname}}
{{/foreach}}
Output:
Group1
Group3
Group4
If-statement
{{if "Newsletter"|in_array:$customer.group_names}}
You are subscribed to our newsletter!
{{else}}
You aren't subscribed to our newsletter, click here to subscribe!
{{/if}}
Output:
You are subscribed to our newsletter!