News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Prefferred method for checking logged in person's shopper group?

Started by mowlman, September 05, 2013, 18:38:23 PM

Previous topic - Next topic

mowlman


Is there a Prefferred method for checking a logged in person's shopper group?
I am using Advannced module mgr and want to check and display a module for certain shopper groups.
Is there a place where the shopper group is saved, example session ? I'd prefer to just check for it  and minimize db calls, if it is already saved somewhere

Or do I need to do a Query?
such as:
$db = JFactory::getDbo();
$user   = JFactory::getUser();
$user1 = ($user->get('id'));   
   
      $query = 'SELECT `virtuemart_shoppergroup_id` '
                . ' FROM `#__virtuemart_vmuser_shoppergroups` '
                . ' WHERE `virtuemart_user_id` =' .$user1 ;

       $db->setQuery($query, 0, 10);
       $Logged_in_shopper_grp_id  = $db->loadResult();

Thank you for your time,
-Bill
Joomla2.5, VM2

servlet

Он-лайн магазин за фототапети http://mishelfoster.com

Milbo

The preferred way is:

$usermodel = VmModel::getModel ('user');
$currentVMuser = $usermodel->getCurrentUser ();
if(!is_array($currentVMuser->shopper_groups)){
$virtuemart_shoppergroup_ids = (array)$currentVMuser->shopper_groups;
} else {
$virtuemart_shoppergroup_ids = $currentVMuser->shopper_groups;
}


If you need a sql, it is very likely that you overseen some function already existing
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/