VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: GJC Web Design on October 21, 2013, 22:45:32 PM

Title: plgVmOnRemoveFromCart trigger not triggering
Post by: GJC Web Design on October 21, 2013, 22:45:32 PM
Hi,

2.0.24  using the plgVmOnRemoveFromCart trigger in a plugin.

The only way I can get it to work is by removing the conditional if(isset($this->cartProductsData[$prod_id])){

removing this it works fine..
full code snippet from components/com_virtuemart/helpers/cart.php ~ line 563

/**
* Remove a product from the cart
*
* @author RolandD
* @param array $cart_id the cart IDs to remove from the cart
* @access public
*/
public function removeProductCart($prod_id=0) {
// Check for cart IDs
if (empty($prod_id))
$prod_id = JRequest::getVar('cart_virtuemart_product_id');
unset($this->products[$prod_id]);
if(isset($this->cartProductsData[$prod_id])){
// hook for plugin action "remove from cart"
if(!class_exists('vmCustomPlugin')) require(JPATH_VM_PLUGINS.DS.'vmcustomplugin.php');
JPluginHelper::importPlugin('vmcustom');
$dispatcher = JDispatcher::getInstance();
$addToCartReturnValues = $dispatcher->trigger('plgVmOnRemoveFromCart',array($this,$prod_id));
unset($this->cartProductsData[$prod_id]);
}
$this->setCartIntoSession();
return true;
}


all tests I try $this->cartProductsData[$prod_id]) is always empty or not set

what is this supposed to be? Searching the whole VM files I can only find it in this function....

Thanks

Title: Re: plgVmOnRemoveFromCart trigger not triggering
Post by: Milbo on October 22, 2013, 11:06:15 AM
It is testing if the product has some custom data and gets only active then.

Seems that you want to use it in general. Then the only solution is to remove it. Or you manipulate your product, adding to the cart. So that it has data there. Hmmm.