VirtueMart Forum

VirtueMart 2 + 3 + 4 => Product creation => Topic started by: rayge on June 24, 2015, 13:19:12 PM

Title: Minimum Purchase Quantity by Shopper group
Post by: rayge on June 24, 2015, 13:19:12 PM
I need to set things like Minimum, maximum Purchase Quantity and Purchase Quantity Steps for certain products BUT they need to be restricted to specific shopper groups.

Is there a way to handle this?
Title: Re: Minimum Purchase Quantity by Shopper group
Post by: rayge on June 24, 2015, 18:10:45 PM
OK here is what i came up with. in productdetails/default_addtocart.php I Added the following code:
//Product array for items that should use Min/step order globally
$exception_sku_array = array(
'QB12',
);
//$user = JFactory::getUser();
//SET MIN ONLY for WHOLSALE except for specific product skus
$usermodel = VmModel::getModel ('user');
$currentVMuser = $usermodel->getCurrentUser();
$currentVMuser->shopper_groups[] = '0'; //This allows pricing for ALL Shopper groups to appear
$virtuemart_shoppergroup_ids = $currentVMuser->shopper_groups;
$virtuemart_shoppergroup_id_str = implode(',',$virtuemart_shoppergroup_ids);
if(
$virtuemart_shoppergroup_ids[0]!='4' //Replace this with your expected shopper ID
&&
!in_array($this->product->product_sku, $exception_sku_array)
) {
$this->product->min_order_level = '1';
$this->product->step_order_level = '1';
}


i added it before this line:
if ((!empty($this->product->customsChilds)) || (!empty($this->product->customfieldsCart))) { ?>

and it seems to be working how i want.
Title: Re: Minimum Purchase Quantity by Shopper group
Post by: rayge on October 14, 2015, 17:38:36 PM
THis isnt working how i had hoped although the FIELD is changed by shopper group, since the ADMIN data shows a minimum quantity it seems to override anything in the front end. there needs to be a session variable or something i can override to handle changing the admin set minimum to 1 instead for retail customers.

has anyone else had to deal with this and what was the solution?

UPDATE: The workaround solution i have come up with is to have 2 products for each product needing to have a specific minimum quantity for each group.. 1 for retail customers and 1 for wholesale.
This SUCKS but it seems to be the best way without having a LOT of code.
Title: Re: Minimum Purchase Quantity by Shopper group
Post by: Khaostar on April 11, 2016, 13:52:03 PM
Hi!

Sorry for bumping the post, but I have the exact same need.

I want to have a minimum quantity for some products depending on the shopper group. Actually, I have to create multiple products to do that. That's a pain. And I don't want to do custom hacks.

Does anyone have a solutuon for this? A plugin maybe?

Thanks!
Title: Re: Minimum Purchase Quantity by Shopper group
Post by: jenkinhill on April 11, 2016, 13:59:58 PM
I have done this using shopper group specific products, but as you say, it does mean cloning & editing each product. I know of no plugin to do this.
Title: Re: Minimum Purchase Quantity by Shopper group
Post by: ARTIFIEDWEB on June 18, 2021, 09:34:11 AM
I know that this is an old thread but we have created a plugin that does exactly this.
You can set rules for min purchase quantity, max purchase quantity, purchase step.
You can select which products, manufacturers or categories these rules will apply to.
And you can set these rules for one or more shopper groups.

If anyone is interested, contact me at george[at]artupweb[dot]com
Title: Re: Minimum Purchase Quantity by Shopper group
Post by: Leone on July 24, 2021, 13:51:19 PM
An example illustrates the combined use of the minimum purchase and staggered values: The minimum order quantity for the item "Wine Châteauneuf-du-Pape red" is 6 bottles for end customers and the article can be purchased in a staggered 6 bottles. The B2C customer can therefore choose between 6, 12, 18, 24, etc. bottles in your shop. However, B2B customers (e.g. restaurants) can only order the identical item from a minimum purchase of 30 bottles, the staggering for them is 12 bottles. So you can order 36, 42, 54, 66 etc. bottles in your shop.