News:

Support the VirtueMart project and become a member

Main Menu

Bug In Stock update virtuemart 2.0.4

Started by teobgeno, April 10, 2012, 04:37:05 AM

Previous topic - Next topic

teobgeno

When i change an order status from (pending,cancel...) to  shipped  In Stock value at product get +(Booked, ordered products) instead of - (Booked, ordered products)

At components/com_virtuemart/models/orders.php line 728

if ($isOut && !$wasOut)     $product_in_stock = '-';
else if ($wasOut && !$isOut ) $product_in_stock = '+';
else $product_in_stock = '=';

i think should be

if ($isOut && !$wasOut)     $product_in_stock = '+';
else if ($wasOut && !$isOut ) $product_in_stock = '-';
else $product_in_stock = '=';

Onother issue is when i delete an order and is for example pending the product(s) of that order (pending also)  does not update in their previous state.
ex. (In Stock 8 Booked, ordered products -1) If i delete this order although the values must change to (In Stock 8 Booked, ordered products 0) they remain  (In Stock 8 Booked, ordered products -1) . So in order to properly delete the order without conflicts in product(s) amounts i must cancel the order first before delete.If someone has a solution for that please reply.
Thank you

teobgeno

To complete this i finally find a solution for the issue when you delete an order and products quantity not properly updated.

At components/com_virtuemart/models/orders.php line 1237
You will see

//TODO Why should the stock change, when the order is deleted? Paypal? Valerie?
//$this->handleStockAfterStatusChangedPerProduct('C', $item->order_status,$item, $item->product_quantity);

I can't figure out what this comment means and if anyone has something for this i would appreciate a reply. Does payment plugins update quantity when redirecting back to site from the payment gateway and in order to prevent conflict from an order delete the delete action does not change quantity ?

So for my case that i have only pay on delivery the quantity is handled only by the actions of the shop's administrator. I uncomment this line

$this->handleStockAfterStatusChangedPerProduct('C', $item->order_status,$item, $item->product_quantity);

and it does not worked :)

The handleStockAfterStatusChangedPerProduct passes C (confirmed) when the product removed from the order and that is not correct. This line must be modified to

$this->handleStockAfterStatusChangedPerProduct('X', $item->order_status,$item, $item->product_quantity);

simbus82

#2
Quote from: teobgeno on April 10, 2012, 05:21:03 AM
To complete this i finally find a solution for the issue when you delete an order and products quantity not properly updated.


Thanks but...please use code tags! ;-)

At components/com_virtuemart/models/orders.php line 1237 change

//TODO Why should the stock change, when the order is deleted? Paypal? Valerie?
//$this->handleStockAfterStatusChangedPerProduct('C', $item->order_status,$item, $item->product_quantity);


to

//TODO Why should the stock change, when the order is deleted? Paypal? Valerie?
$this->handleStockAfterStatusChangedPerProduct('X', $item->order_status,$item, $item->product_quantity);


Joomla! 2.5.16 & VM 2.0.24b

Studio 42

Hi,

If you use 2.04 you must update tables (in normal case the installer do it) and verify the stock updates.

It's only implemented since some weeks but now you can decide how to manage your stock with the status changes in order and add more status but handle correctly with your specifications.

Patrick

simbus82

Quote from: Electrocity on April 10, 2012, 15:31:24 PM
Hi,

If you use 2.04 you must update tables (in normal case the installer do it) and verify the stock updates.

It's only implemented since some weeks but now you can decide how to manage your stock with the status changes in order and add more status but handle correctly with your specifications.

Patrick


In the upgrade from 2.0.2 to 2.0.4, how we can verfy if we need to upadate tables after the upgrade too?
Joomla! 2.5.16 & VM 2.0.24b

Studio 42

in ROOT/administrator/index.php?option=com_virtuemart&view=updatesmigration
or menu
Tools
> Control Panel

Tab : DB Tools
Click >>
Install tables
or if necessary
update them

Studio 42

in ROOT/administrator/index.php?option=com_virtuemart&view=updatesmigration
Install tables
or if necessary
update them

For the stock you are right i have invert the states.
Fixed now see attached files or update from SVN

overide \administrator\components\com_virtuemart\models\orders.php

[attachment cleanup by admin]

simbus82

Quote from: Electrocity on April 10, 2012, 17:24:34 PM
in ROOT/administrator/index.php?option=com_virtuemart&view=updatesmigration
or menu
Tools
> Control Panel

Tab : DB Tools
Click >>
Install tables
or if necessary
update them


if anyone run this without having problems... nothing appens or it is a bad action?

thanks for the file for orders!
Joomla! 2.5.16 & VM 2.0.24b

teobgeno

Can you also explain me the

//TODO Why should the stock change, when the order is deleted? Paypal? Valerie?

At components/com_virtuemart/models/orders.php line 1237


//TODO Why should the stock change, when the order is deleted? Paypal? Valerie?
//$this->handleStockAfterStatusChangedPerProduct('C', $item->order_status,$item, $item->product_quantity);


Because i have uncomment this line and modified it to

//TODO Why should the stock change, when the order is deleted? Paypal? Valerie?
$this->handleStockAfterStatusChangedPerProduct('X', $item->order_status,$item, $item->product_quantity);


Thank you