Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Still able to purchase an item that's set to 'Out of Stock' if it was added to the basket prior to being made out of stock


JoshBowe

Recommended Posts

Hi,

 

I'm running an osCommerce 2.3.1 store and I've run into a bit of a problem, one of the features of having an account with an osCommerce store is that if someone adds a product to their basket, then signs out, the next time they sign in the product will still be in their basket.

 

This is all well and good until someone adds something to their basket, we remove it from stock and it still stays in their basket. They can then continue to make the purchase even though the item is out of stock!

 

I have tried setting to 'Allow Checkout' to 'False' and it's still possible. I set up a clean osCommerce install and I still encounter this problem.

 

Is there anyway to overcome this problem?

 

Thanks.

Link to comment
Share on other sites

@@JoshBowe

 

 

Since you made the modification to allow the item to stay in their cart, you may want to run the stock check again (originally found in the checkout_process.php). The modifications you made should have included a stock check.

 

 

// Stock Check

$any_out_of_stock = false;

if (STOCK_CHECK == 'true') {

for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {

if (tep_check_stock($order->products[$i]['id'], $order->products[$i]['qty'])) {

$any_out_of_stock = true;

}

}

// Out of Stock

if ( (STOCK_ALLOW_CHECKOUT != 'true') && ($any_out_of_stock == true) ) {

tep_redirect(tep_href_link(FILENAME_SHOPPING_CART));

}

}

 

 

That is the code, you will have to determine where to place it now.

 

 

 

Chris

Link to comment
Share on other sites

Hi Chris, that code is already in my checkout_process.php file.

 

I'm not sure what you mean by modifications either? This problem occurs on a completely fresh install of OSC.

 

Thank you.

Link to comment
Share on other sites

@@JoshBowe

 

A completely fresh install would mean YOU DIDN'T CHANGE ANY OF THE ORIGINAL CODE......you already said you made a modification to keep the customers selections in their cart. That modification is preventing the stock check from working properly. What I am suggesting is to add the stock check AGAIN where the original code was modified, so that if they come back and the item is no longer available, then it will inform them in the shopping_cart.php

 

 

 

Chris

Link to comment
Share on other sites

@@JoshBowe

 

A completely fresh install would mean YOU DIDN'T CHANGE ANY OF THE ORIGINAL CODE......you already said you made a modification to keep the customers selections in their cart. That modification is preventing the stock check from working properly. What I am suggesting is to add the stock check AGAIN where the original code was modified, so that if they come back and the item is no longer available, then it will inform them in the shopping_cart.php

 

 

 

Chris

Sorry, perhaps I should've been more clear. Registered users shopping carts will save with a fresh install, it's not a modification.

Link to comment
Share on other sites

@@JoshBowe

 

osCommerce v2.3.1 ends the sessions when the customer logs out. If they still have something that was added to their cart previously, they would be directed to the checkout_process again which would check the stock level and inform the customer it was out of stock in the shopping_cart if they tried to purchase it. By default, as soon as they open shopping_cart.php the customer is notified and prevented from checking out.

 

 

 

Chris

Link to comment
Share on other sites

@@DunWeb

 

The way that my osCommerce store is set up doesn't use automated stock levels though, when we've not got a product in stock we just set it as inactive (I should've stated this from the start, I apologise).

 

So the problem actually is that if a customer has an item in their shopping cart, and we set it to inactive they can still go through with the purchase.

 

Thanks.

Link to comment
Share on other sites

@@JoshBowe

 

Confirmed.

 

Not a bug exactly, but certainly something that needs looking at.

 

You can solve this by adding in an extra check for products_status in the tep_check_stock function.

 

Also, in checkout_shipping.php add a test for stock checking which would redirect to the shopping_cart.php page - this I think should be default osCommerce behaviour, rather than do it checkout_process...which is too far into the checkout process to really be of value. Note that this assumes bypass of shopping_cart.php page which is entirely possible by clicking "checkout" (which goes to checkout_shipping.php).

Link to comment
Share on other sites

@@burt

 

Hi burt, I'm not exactly the most competent coder in PHP. How would I go about doing this?

 

  if (STOCK_CHECK == 'true') {
    $stock_check = tep_check_stock($products[$i]['id'], $products[$i]['quantity']);
    if (tep_not_null($stock_check)) {
	  $any_out_of_stock = 1;
	  $products_name .= $stock_check;
    }
  }

 

Is that the section I need to change?

Link to comment
Share on other sites

  • 2 weeks later...

i can help, was working on this only today for a custom mod that allows lead time checkouts

 

I have some custom mods that you need to edit out,:

 

checkout_conformation.php

 

}

//Lead time check

if ($order->products[$i]['lead_time'] == '1'){$any_out_of_stock = false;};

 

if ((STOCK_ALLOW_CHECKOUT != 'true')&&($any_out_of_stock == true)){

for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {

tep_redirect(tep_href_link(FILENAME_SHOPPING_CART));

 

}

}

}

 

 

----------------

checkout_payment.php

 

// Stock Check

if ( (STOCK_CHECK == 'true') && (STOCK_ALLOW_CHECKOUT != 'true') ) {

$products = $cart->get_products();

for ($i=0, $n=sizeof($products); $i<$n; $i++) {

if($products[$i]['lead_time']== '0'){

if (tep_check_stock($products[$i]['id'], $products[$i]['quantity'])) {

tep_redirect(tep_href_link(FILENAME_SHOPPING_CART));

break;

}

}

}

}

 

----------------

 

 

Remove the red bits.

if your still having issues comment out

like this:

//tep_redirect(tep_href_link(FILENAME_SHOPPING_CART));

 

---> everthing should go through to checkout_conformation.php

 

once you click checkout!.. it calls checkout_process.php.

 

look for :

 

require(DIR_WS_CLASSES . 'order.php');

$order = new order;

 

// Stock Check

$any_out_of_stock = false;

if (STOCK_CHECK == 'true') {

for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {

if (tep_check_stock($order->products[$i]['id'], $order->products[$i]['qty'])) {

$any_out_of_stock = true;

}

}

// Out of Stock

if ( (STOCK_ALLOW_CHECKOUT != 'true') && ($any_out_of_stock == true) ) {

if (($order->products[$i]['lead_time']!= '1')&&(STOCK_LEAD_TIME_ALLOW_CHECKOUT != 'true')){tep_redirect(tep_href_link(FILENAME_SHOPPING_CART));}

}

}

 

---------

 

with these steps you can fualt find your problem. hope this helps.

 

$payment_modules->update_status();

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...