I need to set the shoppergroup for guest users based on a region parameter (that they choose).

I thought that using the following inside a system plugin (onAfterDispatch) would work:

// Getting a registered user and piggy-backing on that.
$user = JFactory::getUser(801);
/** @var TableVmusers $vm_user */
$vm_user_model = new VirtueMartModelUser();
$vm_user = $vm_user_model->getUser();
$vm_user->JUser = $user;
$region = JFactory::$application->input->get('region');
$vm_user->shopper_groups = [0 => $region];

But it doesn't seem to work.

  • 1
    JFactory::$application will cause an error. Remove the $ before application
    – Lodder
    Commented May 12, 2015 at 13:25
  • $region is actually initialised and works, that's not the problem, I'm not sure how to redefine the shopper group so that VM will actually respect it. Commented May 12, 2015 at 13:33

1 Answer 1


I figured out that Shopper Groups are completely linked to a logged in user and cannot be manipulated in your event stack (even with a System plugin). You need to be logged in as a user and that user needs to be assigned a Shopper Group inside the Virtuemart component.

So in the end, I created a user for each of the Shopper Groups I wanted to use and then using a plugin, I manually logged in my guest as that user and got the correct Shopper Group prices to show up.

A terrible work around, but I'm still not convinced there's any other way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.