VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Coding Central => Topic started by: Genius WebDesign on May 10, 2015, 04:32:22 AM

Title: How to programmatically set Virtuemart shopper group for guest user?
Post by: Genius WebDesign on May 10, 2015, 04:32:22 AM
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?

Title: Re: How to programmatically set Virtuemart shopper group for guest user?
Post by: Genius WebDesign on May 10, 2015, 16:01:14 PM
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)
Title: Re: How to programmatically set Virtuemart shopper group for guest user?
Post by: Milbo on May 27, 2015, 12:57:00 PM
No, there is a function


$shoppergroupmodel = VmModel::getModel('ShopperGroup');
$site = JFactory::getApplication ()->isSite ();
$shoppergroupmodel->appendShopperGroups($this->_shopperGroupId,$user,$site,$vendorId);
Title: Re: How to programmatically set Virtuemart shopper group for guest user?
Post by: zesgar on June 29, 2015, 23:46:11 PM
Any luck on finding a way to pro-grammatically set the shopper group?
Title: Re: How to programmatically set Virtuemart shopper group for guest user?
Post by: mabeall32 on July 06, 2015, 20:55:23 PM
how do you add the function