Hi,
Thanks for pointing me to the right (I think) direction. I solved in this way:
1) Inside the validate_free_orders plugin, file validate_free_orders.php I changed the status from "confirmed" to "free" inside the onAfterOrderCreate and onBeforeOrderCreate functions:
function onBeforeOrderCreate(&$order,&$send_email){
if(empty($order) || !isset($order->order_full_price))
return;
if(bccomp($order->order_full_price,0,5)==0){
//$order->order_status = 'confirmed'; Elena
$order->order_status = 'free';
}
}
function onAfterOrderCreate(&$order){
//if($order->order_status == 'confirmed'){ Elena
if ($order->order_status == 'free') {
$class = hikashop_get('class.cart');
$class->cleanCartFromSession();
}
}
Then inside administrator/component/com_hikashop/classes/order.php I inserted a check for the "free" status after the onAfterOrderCreate trigger and, in that case, I inserted the change of the status to confirmed and the trigger of the onAfterOrderUpdate event, that is, at line 153 in my file:
$dispatcher->trigger( 'onAfterOrderCreate', array( & $order,&$send_email) );
//Elena
if ($order->order_status == 'free') {
$order->order_status = 'confirmed';
$dispatcher->trigger( 'onAfterOrderUpdate', array( & $order,&$send_email) );
}
//Elena
if($send_email){
In fact, the plugin that changes the group correctly wait that the payment is received: the order is pending when it's created and become confirmed after the payment, so the plugin is linked to the onAfterOrderUpdate event.
Instead, when the order is free, then it "is born" confirmed, and the onAfterOrderUpdate event is not triggered.
Now it works, but please let me know if you should see any possible problem arising from this solution.
Thanks again
Elena