Here I am sharing the virtuemart code snippet to display special quantity option to a particular shopper group. So for example if you want that wholesalers group must buy the minimum product quantity in the multiply of 5 so 5,10,15 and so on, and for rest of the groups, quantity setting remain as it is so they can buy either 1,2,3… or as many numbers.
1. Identify shopper_group_id
The very first thing you need to do is to find out the “shopper_group_id”, in virtuemart for which you want to display special quantity option. So here is the way to find out the shopper_group_id –
Joomla admin – > Virtuemart -> Shopper -> List Shopper Group. Now mouse over on the particular group and look to the status bar of your browser for shopper_group_id and memorize the # displaying after hopper_group_id=.
2. Adding code to display dropdown with special quantity options
a. Navigate to -
/administrator/components/com_virtuemart/classes/ps_product_attribute.php and locate the function “show_quantity_box”
b. Search for the bellow code
//Start output of quantity
//Check for incompatabilities and reset to normal
if( CHECK_STOCK == '1' && ! $product_in_stock ) {
$display_type = 'hide' ;
}
if( empty( $display_type ) || (@$display_type == "hide" && $child == 'Y') || (@$display_type == "radio" && $child == 'YM') || (@$display_type == "radio" && ! $child) ) {
$display_type = "none" ;
}
c. Place the code just below the above one
$auth = $_SESSION['auth'];
if($auth["shopper_group_id"]==6) {
$display_type = "drop" ;
$quantity_options['quantity_box'] = "drop";
}
Don’t forget to update the shopper_group_id in the above code with the one you just memorized or what you grabbed from the status bar as I instructed in first step. Save the file. Now you will have a dropdown option in your product page.
3. Fill dropdown with special quantity
Open database admin of your site by entering in phpMyAdmin and execute the bellow query in SQL tab
UPDATE `databasename`.`jos_vm_product` SET `quantity_options` = 'none,0,50,6';
Just don’t forget to update the
a. “databasename” with actual database name
b. “none,5,50,5” where first “5” refers to the default first option of dropdown. “50” referrers to maximum or say last option of dropdown. Second “5” refers to multiple #, so 5×1=5, 5×2=10 and so on till the multiply answer reaches to 50.
Here you are done all code implementation, just go ahead and login to your site with a user who has been assigned as a wholesaler group or the particular group for which whom you made this all settings for.






