Extending $customer and inherited class list

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
nviusguy
Ensign (ENS)
Ensign (ENS)
Posts: 5
Joined: Fri Oct 26, 2007 5:38 pm

Extending $customer and inherited class list

Post by nviusguy » Sat Oct 27, 2007 7:31 pm

Hello,

A few questions:

1> What is the best way to extend ($customer). We have a multi-tiered subscription model and have new user roles:

Free Registration
Subscriber (has purchased 1 or more subscriptions, set on checkout of a subscription)
Premium Subscriber (has purchased 1 or more subscriptions with a premium attribute)

and want to create new functions like $customer.getRoles or $customer.IsSubscriber.

2> What is the best way to extend the registration/checkout section to add profile additions/value pairs via UserAttributes table, and be able to extend this to call and set these? Is there underlying functionality not documented/exposed to do this, or do we need to make a class and data handling to do this?

3> In addition, we have run into several cases where there are references to objects where we don't have the benefit of knowing what the reference is. Can you point us to the right files that set the reference for customer and/or do you have an SDK snippet that would list out the common attributes/functions on these? It would really help to be able to look them up in VS.

Thanks in Advance!

--ron

User avatar
Logan Rhodehamel
Developer
Developer
Posts: 4116
Joined: Wed Dec 10, 2003 5:26 pm

Post by Logan Rhodehamel » Mon Oct 29, 2007 9:14 am

1) Keep in mind that roles are assigned to users indirectly, via group memberships.

Code: Select all

<b>Check for role:</b><br>
#if ($User.IsInRole("MyRoleName"))
You are in my role
#else
You are not in my role
#end
<br><br>
<b>Roles I am in:</b><br>
#foreach($userGroup in $User.UserGroups)
#set ($group = $userGroup.Group)
#foreach($groupRole in $group.GroupRoles)
$groupRole.Role.Name<br>
#end
#end
2) You can use the "UserSettingsCollection" class, corresponding to the ac_UserSettings table. C# code might look like this:

Code: Select all

//SET A VALUE
User currentUser = Token.Instance.User;
currentUser.Settings.SetValueByKey(key, value);
//READ A VALUE
string favoriteColor = currentUser.Settings.GetValueByKey("favorite color");
The keys for the user settings must be unique.

3) Check this thread:

viewtopic.php?t=5511

It's basically just a listing of all the classes, methods, and properties. We have to update our process to generate the help documentation to work with a new tool, so the descriptions are missing.
Cheers,
Logan
Image.com

If I do not respond to an unsolicited private message, it's not because I'm ignoring you. It's because the answer to your question is valuable to others. Try the new topic button.

Post Reply