order-item-status is not updated correctly when order is confirmed

Started by carsten888, March 24, 2012, 10:21:47 AM

Previous topic - Next topic

carsten888

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!

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

brentonking

Am also having this same problem. Happens in Joomla 1.5 also. Very odd. Anyone know what the issue is here?

teobgeno

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);



}



}



teobgeno

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);

hkymre

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.

teobgeno


Jan2412

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!

Milbo

Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Jan2412

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!

Milbo

Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/