VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: carsten888 on March 24, 2012, 10:21:47 AM

Title: order-item-status is not updated correctly when order is confirmed
Post by: carsten888 on March 24, 2012, 10:21:47 AM
When there is more then one product on an order, and the status of the order is changed, the order status of each of the order-items is not updated correctly. Only 1 of the items is updated, not the others.

This happens when the order is updated from the backend but also when the order is updated after a payment is made!
(http://www.engelweb.nl/images_online/vm2.jpg)
Even if the checkbox 'Update status for all lines?' is checked or not.

(and the button 'cancel' does not work here)

Joomla 2.5.3
VM 2.0.2
Title: Re: order-item-status is not updated correctly when order is confirmed
Post by: brentonking on March 29, 2012, 04:30:30 AM
Am also having this same problem. Happens in Joomla 1.5 also. Very odd. Anyone know what the issue is here?
Title: Re: order-item-status is not updated correctly when order is confirmed
Post by: teobgeno on March 29, 2012, 20:04:31 PM
I have the same issue too in joomla 1.5.25 with Vm 2.0.2

At components/com_virtuemart/models/orders.php
Line 264
function updateSingleItem
After some tests on this function seems that $orderdata object is not have always the virtuemart_order_item_id key  that $table->bindChecknStore($orderdata,true);  needs in order to update the item status of the order.
I made a modification on this function and seems to be ok now. Because this modification is inside the core files of virtuemart and not completly tested i provide the code below for a temporary solution until virtuemart team release the fix for this bug .


public function updateSingleItem($virtuemart_order_item_id, &$orderdata)
{
         

//fix
$virtuemart_order_item_id='';
//fix

// Update order item status
if(empty($virtuemart_order_item_id)){


$q = 'SELECT virtuemart_order_item_id
FROM #__virtuemart_order_items
WHERE virtuemart_order_id="'.(int)$orderdata->virtuemart_order_id.'"';
$db = JFactory::getDBO();
$db->setQuery($q);
$virtuemart_order_item_ids = $db->loadResultArray();


}else {
if(!is_array($virtuemart_order_item_id)) $virtuemart_order_item_ids = array($virtuemart_order_item_id);
}

        $prod_ids=array();
foreach($virtuemart_order_item_ids as $id){

$table = $this->getTable('order_items');
$table->load($id);

$oldOrderStatus = $table->order_status;


// JPluginHelper::importPlugin('vmcustom');
// $_dispatcher = JDispatcher::getInstance();
// $_returnValues = $_dispatcher->trigger('plgVmOnUpdateSingleItem',array($table,&$orderdata));
           
           //print_r($orderdata->order_status);
     $prod_ids[]=$table->virtuemart_product_id;

    //fix
    $db = &JFactory::getDBO();
$db->setQuery($orderdata->_db->_sql);
$dataOrd=$db->loadAssoc();
$orderdata->virtuemart_order_item_id=$dataOrd[virtuemart_order_item_id];
//fix

   

$table->bindChecknStore($orderdata,true);

/* Update the order item history */
//$this->_updateOrderItemHist($id, $order_status, $customer_notified, $comment);


$errors = $table->getErrors();
foreach($errors as $error){
vmError( get_class( $this ).'::store '.$error);
}



$this->handleStockAfterStatusChangedPerProduct($orderdata->order_status, $oldOrderStatus, $table,$table->product_quantity);



}



}

Title: Re: order-item-status is not updated correctly when order is confirmed
Post by: carsten888 on March 29, 2012, 20:22:03 PM
thank you.
Title: Re: order-item-status is not updated correctly when order is confirmed
Post by: teobgeno on March 29, 2012, 20:36:21 PM
I had onother issue regarding the stock quantity at joomla 1.5.25 vm 2.0.2 .


When i deleted an order with 1 item from admin the Booked, ordered products of this product was 1 after removing the order when it should be 0.
At components/com_virtuemart/models/orders.php -> function removeOrderLineItem

the line
$this->handleStockAfterStatusChangedPerProduct('C', $item->order_status,$item, $item->product_quantity);
i think should be
$this->handleStockAfterStatusChangedPerProduct('X', $item->order_status,$item, $item->product_quantity);
Title: Re: order-item-status is not updated correctly when order is confirmed
Post by: hkymre on April 20, 2012, 23:17:32 PM
Do you know if this is fixed in 2.0.6?
It's causing me problems with downloads are they link is not being sent as parts of multiple orders aren't confirmed.
Title: Re: order-item-status is not updated correctly when order is confirmed
Post by: teobgeno on April 21, 2012, 01:03:16 AM
As far as i know this is fixed on vm 2.0.6
Title: Re: order-item-status is not updated correctly when order is confirmed
Post by: Jan2412 on September 17, 2012, 12:35:24 PM
I have a similar problem as the thread opener carsten888 with the actual version of Virtuemart 2.0.11b.
If I change the order status of the whole order, the order status of the items will be overwritten with this status (independent of the option "Update status for the whole line")

Does anybode know how to fix it? The intent of my question is to chancel one item of the order and not the whole order...

Thanks in advance!
Title: Re: order-item-status is not updated correctly when order is confirmed
Post by: Milbo on September 17, 2012, 14:13:33 PM
Thanks,

fixed
Title: Re: order-item-status is not updated correctly when order is confirmed
Post by: Jan2412 on September 17, 2012, 18:03:36 PM
Hello Milbo,

in Virtuemart 2.0.11c this function works. Thanks for the quick fix!

But if a set the status of one item of the order to chanceled I would suppose that this item will be canceled out of the order and that the overall amount of the order would be decreased. Is this feature already integrated in VM? That would be very helpful...

Thanks in advance!
Title: Re: order-item-status is not updated correctly when order is confirmed
Post by: Milbo on September 18, 2012, 21:09:39 PM
Order editing, sorry not yet, but it is in the pipe