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

How to programmatically set Virtuemart shopper group for guest user?

Started by Genius WebDesign, May 10, 2015, 04:32:22 AM

Previous topic - Next topic

Genius WebDesign

Hi,

My client wants me to program a plugin that applies the guest user to different shopper groups based on language.

Example:
A user visits the site and my code detect from $_SERVER['HTTP_ACCEPT_LANGUAGE'] that the user has language "da" (Danish)
Then I need to update the VM session for the guest user with shopper group "Danish customer"

Another example:
A user visits the site and my code detect from $_SERVER['HTTP_ACCEPT_LANGUAGE'] that the user has language "sv" (Swedish)
Then I need to update the VM session for the guest user with shopper group "Swedish customer"

The question is, how do I programmatically set the Virtuemart shopper group in the session?
Is there a function I can use, and if I need to make a plugin what class must I extend in this case?


Genius WebDesign

I have done some digging in various core files to locate any function that handle session for shopper groups, and it seems that the shopper group is not stored in session at all..
Is this correct? 
(using Virtuemart v. 2.6)

Milbo

No, there is a function


$shoppergroupmodel = VmModel::getModel('ShopperGroup');
$site = JFactory::getApplication ()->isSite ();
$shoppergroupmodel->appendShopperGroups($this->_shopperGroupId,$user,$site,$vendorId);
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

zesgar

Any luck on finding a way to pro-grammatically set the shopper group?