News:

Support the VirtueMart project and become a member

Main Menu

[FIXED] Serious bug with Stock Levels in 1.1.2

Started by willowtree, November 11, 2008, 16:30:12 PM

Previous topic - Next topic

willowtree

Basically, stock levels are not being managed in 1.1.1

I know that this morning i set the quantity of a product to 1, and i have just had 2 orders arrive for that 1 product, about 20 mins apart, and when I checked it still thought that there was still 1 in stock. (It should now be -1, in fact it should not have let the econd order go through at all.)

Both orders are showing as payment received as they were immediately paid via PayPal. I have check stock enabled in the config, but its obviously not reducing stock as purchases are made.

EDIT: Changed title to 1.1.2 as it also refers to that
Please add your VM and Joomla Version to your signature to make it easier to help you:

Most of my code posted in the forum is for VirtueMart 1.0  -  not for 1.1

jjk

I'm using Joomla 1.5.8 and VM 1.1.2 latest nightly build and the stock level is reduced after an order here.

Don't know what is the source of the problem with the versions you are using, but considering that the Joomla Team announced the end of support for the Joomla 1.0 series in July, it's perhaps time to think about migrating to the latest version.
(it's probably easier now than one or two years later  ;))
Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations

willowtree

it probably would be easier, unfortunately i have another componant that is vital to my site that is not compatible with jm 1.5. Having people constantly tell me how I need to upgrade is getting tiring.

I appreciate knowing that it is fixed in 1.1.2, i just hope other things are not broken if I upgrade. Like when I upgraded from 1.0 to 1.1 and now worldpay doesn' t work either, so I need to do another upgrade to get what should be basic functionalty back, and reapply all the other hacks again to get all the other functions/features that vm doesn't come with out of the box.

It's all getting too tiring, right now I'm looking at upgrading jm and swapping vm for an app that I can actually use and that will also do the functionality of the componant this is making me stick to 1.0


Please add your VM and Joomla Version to your signature to make it easier to help you:

Most of my code posted in the forum is for VirtueMart 1.0  -  not for 1.1

jjk

Quote from: willowtree on November 11, 2008, 21:29:02 PM
i just hope other things are not broken if I upgrade...

As a long term VM user I'm shure you test major upgrades locally first - I would never change a running system without testing it on a local copy of the live site first. There are just too many things that can go wrong. (I believe in Murphy's law - "Anything that can go wrong, will go wrong" and "There is always one more bug"  ;D)
Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations

willowtree

sometimes things aren't obvious though, and something like this I would expect to be tested before a release was declared stable.
Please add your VM and Joomla Version to your signature to make it easier to help you:

Most of my code posted in the forum is for VirtueMart 1.0  -  not for 1.1

willowtree

OK, I've reinstalled VM FROM scratch. Completley deleted, and reinstalled, and reuploaded the database.

I STILL have this problem. stock levels are  not reduced after an order has been placed.

I view this as a fundamental flaw.
Please add your VM and Joomla Version to your signature to make it easier to help you:

Most of my code posted in the forum is for VirtueMart 1.0  -  not for 1.1

willowtree

I've just done a search o n all the files in the classes folder and can't see that the product is being reduced anywhere for a 'normal' order. I can see it in order_edit and order_change, but not anywhere else?
Please add your VM and Joomla Version to your signature to make it easier to help you:

Most of my code posted in the forum is for VirtueMart 1.0  -  not for 1.1

jjk

The only thing that currently comes into my mind is that you are using child products and might have set a stock level for your parent product (check your SKUs). If you make use of the child product feature, the buyer actually NEVER orders your parent product and any stock level you set for the parent product won't ever be reduced.

Also, remember that the default stock list hides those products (and SKUs) with a stock level of 0 or -1 unless you select 'List all products'. So you might look at the parent product in the inventory list after you received orders which reduced the stock to 0 or i.e. -1 (which would explain what you described in your original post).

Stock control still works fine for me  :D
Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations

willowtree

nope, not using child products. which version of joomla are you using?
Please add your VM and Joomla Version to your signature to make it easier to help you:

Most of my code posted in the forum is for VirtueMart 1.0  -  not for 1.1

jjk

#9
Quote from: willowtree on December 11, 2008, 13:22:17 PM
...which version of joomla are you using?

Joomla 1.5.8 stable and VM 1.1.2 nightly build 1564 - running localhost on xampp 1.6.8
Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations

willowtree

I'm on joomla 1.0 - it seems the problem is limited to this version.
Please add your VM and Joomla Version to your signature to make it easier to help you:

Most of my code posted in the forum is for VirtueMart 1.0  -  not for 1.1

willowtree

OK, I'm still having this problem. I think the relevant code is in ps_checkout:

// Update Stock Level and Product Sales, decrease - no matter if in stock or not!
$q = "UPDATE #__{vm}_product ";
$q .= "SET product_in_stock = product_in_stock - ".(int)$cart[$i]["quantity"];
$q .= " WHERE product_id = '" . $cart[$i]["product_id"]. "'";
$db->query($q);
//echo $q;


I added the echo, and the query looks correct, I can run it on the database directly and it's fine, and its echoing the query out so its obviously running the code, but it is definatly NOT decreasing the product_in_stock?

Example. I had 25 of an item in stock. I placed an order for 20 of them, and it still said 25 in stock. I then cancelled the order in the back end, now I have 45 in stock!
Please add your VM and Joomla Version to your signature to make it easier to help you:

Most of my code posted in the forum is for VirtueMart 1.0  -  not for 1.1

jjk

#12
just for your info - this is the code from VM 1.1.2 (notice: no 'echo'), which works correctly along with Joomla 1.5.8.

// Update Stock Level and Product Sales, decrease - no matter if in stock or not!
$q = "UPDATE #__{vm}_product ";
$q .= "SET product_in_stock = product_in_stock - ".(int)$cart[$i]["quantity"];
$q .= " WHERE product_id = '" . $cart[$i]["product_id"]. "'";
$db->query($q);

$q = "UPDATE #__{vm}_product ";
$q .= "SET product_sales= product_sales + ".(int)$cart[$i]["quantity"];
$q .= " WHERE product_id='".$cart[$i]["product_id"]."'";
$db->query($q);
Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations

willowtree

I added the echo to check that the query was being correctly generated.

with it echo'd out I applied the query to my database directly and it worked. But It's not working as orders are placed.

If there is somewhere else that this is supposed to happen I'll check there.

the site is www.willowtreecrafts.co.uk if you wanted to test it. You should be able to see quantities in stock as you browse, place an order for something and see if the quantities have changed,
Please add your VM and Joomla Version to your signature to make it easier to help you:

Most of my code posted in the forum is for VirtueMart 1.0  -  not for 1.1

willowtree

Please add your VM and Joomla Version to your signature to make it easier to help you:

Most of my code posted in the forum is for VirtueMart 1.0  -  not for 1.1