Hi,
Thanks for your feedback.
Adding a trigger in the updateQuantityAndSales function makes sense.
Now, I can't agree with the name of the trigger event since the saving in hikashop_order_product is actually done in the save function of the same file, after the call to updateQuantityAndSales.
Also, I would prefer to add the trigger outside of the loop. In fact, I would rather add one before the loop and one after the loop, like so:
JPluginHelper::importPlugin('hikashop');
$app = JFactory::getApplication();
$app->triggerEvent('onBeforeProductStockUpdate', array(&$updates, $cancel));
if(!empty($updates)) {
... loop code ...
$app->triggerEvent('onAfterProductStockUpdate', array(&$updates, $cancel));
}
That way, plugins can even cancel the stock update by emptying the $updates array in the onBeforeProductStockUpdate event.
What do you think ? Does this still work for the custom plugin you're working on ?