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

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

Previous topic - Next topic


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,
Joomla2.5, VM2


Он-лайн магазин за фототапети


The preferred way is:

$usermodel = VmModel::getModel ('user');
$currentVMuser = $usermodel->getCurrentUser ();
$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: