Author Topic: Automatically assign shopper group based on Joomla User group  (Read 177 times)

SoTrue

  • Beginner
  • *
  • Posts: 47
    • Site Wide Design
Hi Guys,

We use a custom registration form to allow shoppers to register as Wholesalers, once registered this puts the user in the Joomla User Group 'Wholesale', but assigns the user to the shopper group "default shopper'. Is there a way so that all users in the Joomla user group 'Wholesale' automatically get assigned to the Virtuemart shopper group 'Wholesale'?

Regards
D

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 7885
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 2.6.22 & 3.2.14
GJC Web Design
VirtueMart and Joomla Developers - php developers http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

SoTrue

  • Beginner
  • *
  • Posts: 47
    • Site Wide Design
Re: Automatically assign shopper group based on Joomla User group
« Reply #2 on: July 24, 2018, 18:51:13 pm »
Thank you, but these do not seem to solve the problem as we use a custom registration form which then adds a user to a Joomla User group and sets the shopper group as default. What we would like is for the group to automatically be assigned to Wholesale if the User group is Wholesale.

I have found a code snippet but cannot seem to understand how it works:

Code: [Select]

$virtuemart_user_id = (int)$formModel->_formData['mytable___userid'];
$address_type = "BT";
$name = $formModel->_formData['mytable___nombre'];
$last_name = $formModel->_formData['mytable___apellido_paterno'];
$first_name = $formModel->_formData['mytable___nombre'];
$middle_name = $formModel->_formData['mytable___apellido_materno'];
$phone_1 = $formModel->_formData['mytable___Telfono_casa'];
$address_1 = $formModel->_formData['mytable___Calle'];
$address_2 = $formModel->_formData['mytable___colonia'];
$city = $formModel->_formData['mytable___Ciudad'];
$virtuemart_state_id = (int)$formModel->_formData['mytable___estado_id'][ 0 ];
$virtuemart_country_id = 138;
$zip = $formModel->_formData['mytable___Codigo_Postal'];

$db =& JFactory::getDBO(); 
$virtuemart_user_id = $db->Quote($virtuemart_user_id);
$address_type =$db->Quote($address_type);
$name = $db->Quote($name);
$last_name = $db->Quote($last_name);
$first_name = $db->Quote($first_name);
$middle_name = $db->Quote($middle_name);
$phone_1 = $db->Quote($phone_1);
$address_1 = $db->Quote($address_1);
$address_2 = $db->Quote($address_2);
$city = $db->Quote($city);
$virtuemart_state_id = $db->Quote($virtuemart_state_id);
$virtuemart_country_id = $db->Quote($virtuemart_country_id);
$zip = $db->Quote($zip);


$db->setQuery("INSERT INTO ultgj_virtuemart_userinfos(virtuemart_user_id,address_type,name,last_name,first_name,middle_name,phone_1,address_1,address_2,city,virtuemart_state_id,virtuemart_country_id,zip) VALUES ($virtuemart_user_id,$address_type,$name,$last_name,$first_name,$middle_name,$phone_1,$address_1,$address_2,$city,$virtuemart_state_id,$virtuemart_country_id,$zip)"); 
$db->query();

$virtuemart_user_id = (int)$formModel->_formData['mytable___userid'];
$customer_number = md5($formModel->_formData['mytable___Usuario']);
$perms = "shopper";

$db =& JFactory::getDBO(); 
$virtuemart_user_id = $db->Quote($virtuemart_user_id);
$customer_number =$db->Quote($customer_number);
$perms = $db->Quote($perms);

$db->setQuery("INSERT INTO ultgj_virtuemart_vmusers (virtuemart_user_id,customer_number,perms) VALUES ($virtuemart_user_id,$customer_number,$perms)"); 
$db->query();

 
 

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 7885
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 2.6.22 & 3.2.14
Re: Automatically assign shopper group based on Joomla User group
« Reply #3 on: July 24, 2018, 22:48:08 pm »
Code: [Select]
$db->setQuery("INSERT INTO ultgj_virtuemart_vmusers (virtuemart_user_id,customer_number,perms) VALUES ($virtuemart_user_id,$customer_number,$perms)"); 

Standard VM3 #___virtuemart_vmusers doesn't have a column 'perms'

shopper groups are recorded in #__virtuemart_vmuser_shoppergroups`

is this VM2 or something?

You need to go further back in the code

$perms = Shopper

if joomla grp == Wholesale then $perms = Wholesale


GJC Web Design
VirtueMart and Joomla Developers - php developers http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation