Using nVelocity to Display or act upon user group

Store UI, layout, design, look and feel; Discussion on the customer facing pages of your online store. Cascading Style Sheets, Themes, Scriptlets, NVelocity and the components in the ConLib directory.
Post Reply
it@isa-arbor.com
Lieutenant (LT)
Lieutenant (LT)
Posts: 54
Joined: Fri Aug 15, 2008 7:56 am

Using nVelocity to Display or act upon user group

Post by it@isa-arbor.com » Tue Nov 04, 2008 10:41 am

We have users who need to log in with an existing account to recieve member pricing. I'd like to display a message in the checkout screen if someone logs in and is not in the member user group, reminding them to use their pre-existing member account (assuming they have one) to receive member pricing.

I thought I'd try using nVelocity to accomplish this, but I am not sure if or how to access the UserGroup name, or even the ID. If I can get at the ID I might be able to use the sample code I've seen to do a quick check and display a message if they are or are not in the member group. How can I access a Users Group IDs or a User Group Names.

I was fiddling with
${UserGroup.GroupID}
$User.Group
... but had no luck.

Thanks in advance.

Ernie

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Using nVelocity to Display or act upon user group

Post by mazhar » Tue Nov 04, 2008 11:26 am

First check ac_Groups table from the database and find the id of your group for example in my case i created a group named MemberGroup and the database id for this group was 9.
Now put the following NVelcocity code in OnePageCheckout scriptlet

Code: Select all

#if(!$customer.IsInGroup(9))
You are not a member
#else
You are a member
#end
It will show the related message depending upon that user is a member of the group or not. For your requirements you can just skip the else part, so that it will be something like as below.

Code: Select all

#if(!$customer.IsInGroup(9))
You are not a member
#end

it@isa-arbor.com
Lieutenant (LT)
Lieutenant (LT)
Posts: 54
Joined: Fri Aug 15, 2008 7:56 am

Re: Using nVelocity to Display or act upon user group

Post by it@isa-arbor.com » Tue Nov 04, 2008 1:15 pm

Mazhar,

Perfect! Perfect! Prefect!

Exactly what I needed.

Thanks,

Ernie

Post Reply