I know this post was a little old so i'm not sure if this will help anyone... I DO NOT certify that this will not break any other part of your Joomla/VM install, but it worked for me on Joomla 1.5.21 with Virtuemart 1.1.5.
Basically, my problem was that I needed a field to assign users to a shopper group during registration. I was not using the euvat, b/c that field did not fit the bill for what i needed.
SO... I modified 2 files found in /administrator/components/com_virtuemart/classes/ and then created a select box for selecting shopper group. Here is a step by step of what i did. PLEASE NOTE: I know this is not the best code or probably the best way to do this, but, for my requirements, it just has to work and this did.
First, I made the following changes/additions to the ps_shopper.php file:
NOTE: Your line numbers may be different than mine.
1) added lines 80 to 82 (directly above case 'age_verification') the following code:
case 'select':
$d['vm_selectshoppergroup'] = vmRequest::getInt('vm_selectshoppergroup');
break;
2) added lines 192 to 194 (again, directly above case 'age_verification') the following code:
case 'select':
$d['vm_selectshoppergroup'] = vmRequest::getInt('vm_selectshoppergroup');
break;
3) added lines 420 to 422 (directly under the if($d['isValidVATID'] statement) the following if statement:
if (!empty($d['vm_selectshoppergroup'])) {
$d['shopper_group_id'] = $d['vm_selectshoppergroup'];
}
4) added lines 759 to 766 (added an else to the if(empty)$d'customer_number'])) statement) the following code:
// else was added for shopper group select
else {
$q = "UPDATE #__{vm}_shopper_vendor_xref SET ";
$q .= "shopper_group_id='". $d['vm_selectshoppergroup'] ."'";
$q .= "WHERE ";
$q .= "user_id='". $user_id ."'";
$db->query($q) or die(mysql_error());
}
5) Save the file.
Next I modified the ps_userfield.php file:
6) open ps_userfield.php
find the following line, for me it was 494.
$rowFieldValues['lst_'.$field->name] = vmCommonHTML::selectList( $Values, $field->name."[]",
and change it to
$rowFieldValues['lst_'.$field->name] = vmCommonHTML::selectList( $Values, $field->name."",
7) open your ftp program and make a backup of your current ps_shopper.php AND ps_userfield.php files8 ) upload the ps_shopper.php and ps_userfield.php files that you just modified.
Finally, I created a shopper group select userfield:
9) login to your joomla admin backend and go to virtuemart.
10) on the left under 'administration' click on manager user fields
11) add a new user field:
- !IMPORTANT - Type: Drop Down (single select)
- !IMPORTANT - Name: vm_selectshoppergroup
- all other variables can be set how you need.
- at the bottom your values should be set up as the title is whatever you want the user to see and the value is the shopper_group_id. If you don't know the shopper group id, then on the left click on 'shopper' and 'list shopper groups' click on a shopper group and look in the url, you will see shopper_group_id=. Take that number and that's your shopper group id
- add however many titles and values (shopper group id's) that you need
example setup:
- Type: Drop Down (Single Select)
- Name: vm_selectshoppergroup
- Title: Are you a wholesaler of us?
- Required: Yes
- All other variables are defaults
- Values
- Title: No Value: 5
- Title: Yes Value: 6
12) Save the new field and test it out.
Again, I make no warranty that this is perfect, but it is what worked for me. This forum has helped me an absolute ton, so I hope this helps someone else.
Edit:
Also, your users can modify this setting in their account if you have "show in account maintenance?" set to yes. If they change this in their account it WILL update their shopper group.