Hi Nicolas,
First of all BIG thanks for your good explanation!
1. This website will need to have the possibility to change orders in a state order I defined as registered. But so far so good over here, as I also disable/hide the option to edit or delete a product when an order in afterword status like created,confirmed,shipped,etc...
2. In the functions of my plugin for onAfterOrderCreate(&$order,&$do) and onAfterOrderUpdate(&$order,&$do).
I defined some extra validations stages, like this for onAfterOrderCreate
if(isset($order->cart->products)) {
$products =& $order->cart->products;
} else {
$products =& $order->products;
}
$this->addNetValues($order,$products);
And in onAfterOrderUpdate
if(isset($order->products)) {
$products =& $order->products;
} else {
$products =& $order->product;
}
$this->addNetValues($order,$products);
Then in my function function addNetValues(&$order, &$products)
if(!empty($products)) {
.....
So I think is good this part, the change of status of order will not be executed inside my function addNetValues
3. One reason I used the query was also to avoid the triggers events called twice after the onAfterOrderUpdate with the use of $orderClass->save($cOrder), so I think is good as it is
4. This option is really to verify the quantity of product on the order and the stock available to avoid mistakes in admin side.
The order in NO case, must have more quantity than the stock available of the products.
That's why I am adding extra validations to the full store in admin side also.
I also created so far the order.override.html, was a little complicated to understand it! After all I need to have the file in front and also in admin html template!! But is done
I have the extended functions save(..) and saveForm(..) on it, is more or less a copy from original with some changes I need to add.
The only thing I don't use in this cases was to call the parent::save but going directly to hikashopClass, again this is to avoid running twice the code and pass over my rules.
$parent = 'hikashopClass';
$parent::save($updateOrder);
So in conclusion and after your help and guidelines, seems I am just missing the quantity validation when I edit a product inside the order!
As I have already made the quantity validation plugin when a order changes.
Perhaps inside my order.overridehtml on saveForm($task = '') {
After line
$data = JRequest::getVar('data', array(), '', 'array');
I add this
$doit = true;
JPluginHelper::importPlugin('hikashop');
$dispatcher = JDispatcher::getInstance();
$dispatcher->trigger('onBeforeSaveForm', array(&$order, $task, &$doit));
if($doit ) {
rest of the code lines
}
And in my plugin add function onBeforeSaveForm and do the validation starting from here.
So let's see how it will work and if passes right with my quantity validation.
I will lets you now.
And BIG THANKS again, because I also know what is giving support in the forum
Regards