News:

Looking for documentation? Take a look on our wiki

Main Menu

Missing plugin event (plgVmOnAddToCart)

Started by sandomatyas, January 18, 2016, 17:59:11 PM

Previous topic - Next topic

sandomatyas

I'm trying to update a VirtueMart 2.0.22 based shop to VirtueMart 3.0.12
Everything seems fine except one thing. There is a vmcustom plugin and it has a plgVmOnAddToCart method.
I checked the old VirtueMartCart class and there is a code like this:
if(!class_exists('vmCustomPlugin')) require(JPATH_VM_PLUGINS.DS.'vmcustomplugin.php');
JPluginHelper::importPlugin('vmcustom');
$dispatcher = JDispatcher::getInstance();
// on returning false the product have not to be added to cart
$addToCartReturnValues = $dispatcher->trigger('plgVmOnAddToCart',array(&$product));

I tried to implement it to VM3 but the new cart class doesn't trigger this method.
There is something like that:
$addToCartReturnValues = $dispatcher->trigger('plgVmOnAddToCartFilter',array(&$product, &$customfield, &$customProductData, &$customFiltered));
But it's been only triggered if the product has customfields.
Is there a reason why it was removed? Is it possible to get this trigger back?

GJC Web Design

GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Milbo

The reason is the security. You cannot rely on forms, they could be manipulated.

At begin, in vm2.0.x times we just used the form of "add product to cart". The customfields created the data. The data was just filtered informatically, but not logically. If a customfield was there, it did something with this data. The problem is that the whole thing is unsecure.

So I changed already for vm2.0.x respectivly vm2.6, that any data must be controlled by the custom. In Vm3, the whole logic is reversed. We store in the cart only the data to reproduce the cart. So the trigger plgVmOnAddToCartFilter is always called, when the cart is initialized (getCart executed first time). And the trigger should call the customfield, which proceses the data.

Actually missing and that was also missing before, a trigger which sets cartdata. But on the other hand, you can do that already with payment and shipment plugins.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

GJC Web Design

GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation