Issue 807 in wp-e-commerce: Stock Inventory levels not reducing upon sale

10 views
Skip to first unread message

wp-e-c...@googlecode.com

unread,
Nov 1, 2011, 10:59:47 AM11/1/11
to wp-e-commerce-googl...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 807 by peter.al...@gmail.com: Stock Inventory levels not reducing
upon sale
http://code.google.com/p/wp-e-commerce/issues/detail?id=807

What steps will reproduce the problem?
1. Place a limited stock item in cart and go to checkout
2. Purchase (I used bank-transfer to test)
3. Stock says "xx of them are reserved for pending or recently completed
orders"
4. Change the order to payment accepted, then shipped, then closed
5. Stock not reduced, they remain in reserved and sit there...

What is the expected output? What do you see instead?


What version of WP e-Commerce are you using? = Version 3.8.7.1
WordPress version? = 3.2.1
Which browser? Firefox

If this issue has been discussed in the forums, please link to the relevant
posts.

Please provide any additional information below.

All other features work fine, unable to convert stock from reserved to sold.
I am expecting the Inventory number to go down once an order has progressed
past the payment accepted status.

I have WP E-Commerce Extra Shipping Options and WP E-Commerce Pick-up
Shipping Modules installed as well.

wp-e-c...@googlecode.com

unread,
Nov 1, 2011, 4:59:02 PM11/1/11
to wp-e-commerce-googl...@googlegroups.com
Updates:
Labels: Version-3.8.7.1 Component-Checkout

Comment #1 on issue 807 by ja...@om4.com.au: Stock Inventory levels not

(No comment was entered for this change.)

wp-e-c...@googlecode.com

unread,
Nov 22, 2011, 11:16:57 AM11/22/11
to wp-e-commerce-googl...@googlegroups.com

Comment #2 on issue 807 by c...@appfromlab.com: Stock Inventory levels not

Adjust wpsc_decrement_claimed_stock($purchlog_id) to execute first instead
of wpsc_clear_stock_claims() in function wpsc_purchlog_edit_status().

The issue arises because we are clearing the stock claims first and when it
comes to updating the balance stock, the code found no claimed stock in the
database therefore balance stock didnt need to be updated.

Would this be the correct way?

Attachments:
wpsc_purchlog_edit_status.diff 1.0 KB

wp-e-c...@googlecode.com

unread,
Nov 22, 2011, 4:26:07 PM11/22/11
to wp-e-commerce-googl...@googlegroups.com

Comment #3 on issue 807 by peter.al...@gmail.com: Stock Inventory levels

Version 3.8.7.2 seems to have fixed this issue for me.

wp-e-c...@googlecode.com

unread,
Nov 22, 2011, 11:06:14 PM11/22/11
to wp-e-commerce-googl...@googlegroups.com

Comment #4 on issue 807 by ja...@om4.com.au: Stock Inventory levels not

The file changes between 3.8.7.1 and 3.8.7.2 are here:
http://plugins.trac.wordpress.org/changeset?old_path=%2Fwp-e-commerce%2Ftags%2F3.8.7.1&new_path=%2Fwp-e-commerce%2Ftags%2F3.8.7.2

Looking at those changes, I can't see any code changes that would have
fixed this bug as part of the 3.8.7.2 release.

wp-e-c...@googlecode.com

unread,
Nov 23, 2011, 4:40:59 AM11/23/11
to wp-e-commerce-googl...@googlegroups.com

Comment #5 on issue 807 by corrupi...@gmail.com: Stock Inventory levels not

I applied the above diff in wpsc_purchlog_edit_status.diff.
Worked for me.

wp-e-c...@googlecode.com

unread,
Mar 17, 2012, 11:26:32 AM3/17/12
to wp-e-commerce-googl...@googlegroups.com

Comment #6 on issue 807 by ngrammal...@gmail.com: Stock Inventory levels

I agree that the issue mentioned in Comment 2 is a bug, but still problems
remain when using the test_merchant, as the original poster obviously does.
First, I need to say I am not an expert at all with wordpress and
wp-e-commerce. I am also using/testing only the test_merchant module, so I
am very well aware of what is done when using the other merchants.
However, after an examination I made, the problem is due to the function
wpsc_clear_stock_claims that is periodically run via wp_cron and deletes
the claimed stock record,
while the order is received and pending (status=2). I think the problem can
be solved by changing line 21 in wpsc-includes/cron.php to:

$sql = $wpdb->prepare( "DELETE FROM " . WPSC_TABLE_CLAIMED_STOCK . " WHERE
`cart_submitted` != '1' AND last_activity < NOW() - INTERVAL %d SECOND",
$seconds );

Now when this function is run either by cron or when the purchase_status is
changed from the Dashboard, no harm is done to these claimed stock records
and this claimed stock will not be available to other users. If payment is
received and/or the items are dispatched or transaction is marked as
completed, there is code in wpsc-transaction_results_functions.php to
permanently decrement stock and delete the record.
So, I guess, the only problem left is to delete the claimed stock record
also if the admin for some reason deletes the purchase from the dashboard.
In this case, the wpsc_delete_purchlog in wp-admin/ajax-and-init.php is
called, so I think I fixed it by changing line 685 to:

if ( $purchlog_status == 5 || $purchlog_status == 1 || $purchlog_status ==
2) {

I tried the above fix and I don't see any problem until now. Can an expert
developer check and tell us if my modifications are fine or not, and also
if they create any problems to other merchants?

Thanks in advance!

PS: Probably the last line change should be changed to:

if ( $purchlog_status == 5 || $purchlog_status == 1 || $purchlog_status ==
2 || $purchlog_status == 6) {

to handle the case of "declined payment" too...

wp-e-c...@googlecode.com

unread,
Jun 2, 2012, 7:08:25 PM6/2/12
to wp-e-commerce-googl...@googlegroups.com

Comment #7 on issue 807 by lister...@gmail.com: Stock Inventory levels not
Hey could you help me, I'm having problems with stock not being reset if
not purchased...

wp-e-c...@googlecode.com

unread,
Jun 3, 2012, 9:46:18 AM6/3/12
to wp-e-commerce-googl...@googlegroups.com

Comment #8 on issue 807 by ngrammal...@gmail.com: Stock Inventory levels
Lister: a) Did you apply my changes? In fact in 3.8.8.1 I have noticed
strange problems where entries of purchased itmes in
WPSC_TABLE_CLAIMED_STOCK are mysteriously deleted after some time. I am
still trying to find why is this happening. b) what WPEC version and what
merchant are you using? c) From what you write, it seems that you should
have entries in WPSC_TABLE_CLAIMED_STOCK with cart_submitted=='0' (not
purchased). Can you check the table with phpmyadmin and confirm this?

wp-e-c...@googlecode.com

unread,
Jun 22, 2012, 8:36:37 PM6/22/12
to wp-e-commerce-googl...@googlegroups.com

Comment #9 on issue 807 by gary...@garyc40.com: Stock Inventory levels not
Issue 891 has been merged into this issue.

wp-e-c...@googlecode.com

unread,
Jul 9, 2012, 9:58:35 AM7/9/12
to wp-e-commerce-googl...@googlegroups.com

Comment #10 on issue 807 by roryjoe.m: Stock Inventory levels not reducing
upon sale
http://code.google.com/p/wp-e-commerce/issues/detail?id=807

I still experience this issue when using Test mode with merchant gateway.

wp-e-c...@googlecode.com

unread,
Aug 9, 2012, 12:31:20 PM8/9/12
to wp-e-commerce-googl...@googlegroups.com

Comment #11 on issue 807 by thepagan...@gmail.com: Stock Inventory levels
Is this issue still not fixed?


wp-e-c...@googlecode.com

unread,
Nov 10, 2013, 12:38:10 PM11/10/13
to wp-e-commerce-googl...@googlegroups.com

Comment #12 on issue 807 by joshberg...@gmail.com: Stock Inventory levels
I'm still having a similar issue.
WP-Ecommerce Version: 3.8.12.1
WP Version :3.5.1
Payment Gateway: PayPal Pro 2.0

My issue comes when an initial order is denied for whatever reason, them
completed immediately after by the same user. If the order is rejected the
system creates an Incomplete Order, then the user is redirected to try
again. When the same user is then successful in checkout the system creates
an Accepted Payment order (with a different order #), but at this point it
doesn't reduce the stock.

If an order is completed successfully the first time, the stock is reduced
correctly.

--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

wp-e-c...@googlecode.com

unread,
Nov 11, 2013, 11:40:24 AM11/11/13
to wp-e-commerce-googl...@googlegroups.com

Comment #13 on issue 807 by benjamin...@gmail.com: Stock Inventory levels
Issues are now handled over on GitHub.

Here are some related issues:
https://github.com/wp-e-commerce/WP-e-Commerce/issues/172
https://github.com/wp-e-commerce/WP-e-Commerce/issues/293
https://github.com/wp-e-commerce/WP-e-Commerce/issues/481

Or add a new one if none of the above covers you issue.
Reply all
Reply to author
Forward
0 new messages