Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Inventory Issue


Guest

Recommended Posts

I've been very happily using osC for a couple of years but seem to have one serious issue. It seems that under certain conditions (that I can't seem to track), stock levels are not reduced upon purchase (or something like that). It leaves me in a jamb from time to time since my products aren't easy to restock.

I had thought it might be old carts that folks pick back up, but I tried an old login I had made and there was an item I couldn't check out due to it being out of stock. Then, someone ordered something a couple of weeks ago that's been out of stock for months.

Now, I've mucked around with the code plenty, Contribs and a bunch of my own butchering. Maybe I did something and maybe it's a contrib. Has anyone seem this and traced the problem or does anyone have some suggestions as to where I might find the trouble?

Link to comment
Share on other sites

Any thoughts here?

 

I have found the same problem, and in my case I have narrowed it down to a multi-buy issue. When a single item is purchased, it always gets tracked properly. However, if multiple items are purchased, sometimes there is a problem. I think (not sure) it has to do with the attributes. Most of my items have 3 attributes, and it always gets messed up when the same item is purchased twice with different attributes. (Like a sweater in 2 different colors - it will only pick up the first one and not deduct the second from inventory.) But it seems that if there are a lot of items, it will also miss the second or third. I have not figured out a fix for this yet. (Higher priorities at the moment, but it's on my list of things to look into.)

 

Good to know someone else has seen this. I'll have to do a more thorough board search to see if I can find a fix. Anyone seen one or know of one? I'm using QT Pro, so I'm pretty sure that's part of the problem.

 

Adrienne

Link to comment
Share on other sites

Hmm, interesting. Maybe i can set up a dummy store and do a bunch of testing. I found the stock changing section of checkout_process.php and will look closely at it. By the way, I have no options or attributes and still get it. This may help to lock down a location or code bit responsible.

Link to comment
Share on other sites

So, here's the code in checkout_process.php that I think is the important part. In my case, nothing is downloadable and I have no options or attributes. Just simple products.

  for ($i=0; $i<sizeof($order->products); $i++) {
// Stock Update - Joao Correia
if (STOCK_LIMITED == 'true') {
  if (DOWNLOAD_ENABLED == 'true') {
	$stock_query_raw = "SELECT products_quantity, pad.products_attributes_filename 
						FROM " . TABLE_PRODUCTS . " p
						LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES . " pa
						 ON p.products_id=pa.products_id
						LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad
						 ON pa.products_attributes_id=pad.products_attributes_id
						WHERE p.products_id = '" . tep_get_prid($order->products[$i]['id']) . "'";
// Will work with only one option for downloadable products
// otherwise, we have to build the query dynamically with a loop
	$products_attributes = $order->products[$i]['attributes'];
	if (is_array($products_attributes)) {
	  $stock_query_raw .= " AND pa.options_id = '" . $products_attributes[$i]['option_id'] . "' AND pa.options_values_id = '" . $products_attributes[$i]['value_id'] . "'";
	}
	$stock_query = tep_db_query($stock_query_raw);
  } else {
	$stock_query = tep_db_query("select products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
  }
  $stock_values = tep_db_fetch_array($stock_query);
// do not decrement quantities if products_attributes_filename exists
  if ((DOWNLOAD_ENABLED != 'true') || (!$stock_values['products_attributes_filename'])) {
	$stock_left = $stock_values['products_quantity'] - $order->products[$i]['qty'];
  } else {
	$stock_left = $stock_values['products_quantity'];
  }
  tep_db_query("update " . TABLE_PRODUCTS . " set products_quantity = '" . $stock_left . "' where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");

}

Link to comment
Share on other sites

PayPal transactions only trigger stock reduction when the customer returns to your site. If they fail to do so, your stock levels won't update properly. This is the case both with the standard PayPal module and the PayPal IPN. Terra

My code for combining PayPal IPN with ** QTPro 4.25 ** osC Affiliate ** CCGV(trad)

and how to solve the invoice already paid error

General info: Allow customer to delete order comment ** FTP Programs & Text Editors ** Amending order email **

Link to comment
Share on other sites

Well i guess that's good and bad. Good that it works but bad that the mystery remains. I only do a couple thousand a year through paypal, but it would have been enough to throw off my inventory. Then again, maybe it is throwing it off. Maybe I have the wrong return URL. I need to go look. Anyone know the correct return to make sure the data gets through right?

Link to comment
Share on other sites

checkout_process.php should be the correct one for the regular paypal. One thing you could if you use several external gateways is to deploy one of the pre-logging order contributions and decrease the stack during logging instead of doing it during checkout_process.php So at least it wouldn't matter what gateway you use.

 

I asked for the ipn earlier, because it includes the pre-logging mechanism and so you could reduce the stock before the customer goes to paypal.

Link to comment
Share on other sites

I just checked and saw that I actually did more like 8 grand + through PP this year. I think that would really throw my numbers off since products avg about $17. They're my only processor other than my Auth.net cc.

I think I will dupe the store and drive it hard for a while to see where if the problem is in a payment method. I hardly do any business by check/mo anymore so it isn't that one. Something mentioned earlier in this post about quantity makes me wonder. Most folks are one of each for my stuff. Not too many buy two or more.

Link to comment
Share on other sites

Glad to hear you might have found a fix. I don't use Paypal at all, though. And given the known error when the same product is ordered twice with different attributes, I'm pretty sure my error is with attribute tracking. So possibly total different error even though the symptoms sounded similar. I guess I'll have to keep looking...

 

Adrienne

Link to comment
Share on other sites

  • 4 months later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...