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.

Related posts:

Author:

is co-founder and author of tips4developer. By profession he is a WordPress and Joomla developer.


Subscribe to email feed

  • RSS
  • Delicious
  • Digg
  • Facebook
  • Twitter
  • Linkedin

Joomla – Allowing

Recently I got an requirement to add multiple email ID’s ...

WordPress - Controll

Page Lists Plus is one of the most use full ...

IE compatible mode

I noticed most of the web developers and designers hate ...

Adding PayPal Donate

Adding PayPal Donate Button in WordPress Post and Page are ...

Multi Browsers CSS H

Here I am sharing few of the very useful multi ...

Joomla – Allowing

Recently I got an requirement to add multiple email ID’s ...

Virtuemart – Setti

In my last project I got a requirement from my ...

3 Best Security Ext

Joomla is one of the fastest growing and best CMS ...

Joomla Conditional S

With the help of Joomla conditional statements you will able ...

Virtuemart - Special

Here I am sharing the virtuemart code snippet to display ...