VirtueMart Forum

VirtueMart 2 + 3 + 4 => Plugins: Payment, Shipment and others => Topic started by: likrish on September 25, 2015, 17:25:24 PM

Title: Force a quantity of 1 and add a product multiple times (without qty updating)
Post by: likrish on September 25, 2015, 17:25:24 PM
Hi,

I want to be able to force the quantity of a product to 1 (easily achieved by hidden field).
However when I add the product a second time, I want the product to be added on a second line.
At the moment Virtuemart simply updates the QTY of the existing product in the cart (if the price is the same).
Ideally I would like to create a plugin that prevents the QTY from being updated and Forces the product onto a separate line.

Any help would be greatly appreciated...
We are developing VM 3.x on Joomla 3.x
Title: Re: Force a quantity of 1 and add a product multiple times (without qty updating)
Post by: K&K media production on September 25, 2015, 20:38:17 PM
Maybe with a customfield plg which adds something to the product to simulate a variant ...

Take a look to the plg development and try a little bit.
Title: Re: Force a quantity of 1 and add a product multiple times (without qty updating)
Post by: PRO on September 25, 2015, 21:27:18 PM
make a hidden custom field,

make the input value a random character string
This will force a new line


In the function plgVmOnDisplayProductFEVM3


// Product Page Display
// is hidden field ONLY in the form and not the custom Params
   function plgVmOnDisplayProductFEVM3(&$product,&$group) {

      if ($group->custom_element != $this->_name) return '';
      $group->display = '<input type="hidden" name="customProductData['.$product->virtuemart_product_id.']['.$group->virtuemart_custom_id.']['.$group->virtuemart_customfield_id.'][hidden]" value="1" />';
return true;
   }