Forums / General Questions / At which stages of checkout is stock checked?

At which stages of checkout is stock checked?

Locked

Started by pickledshark on 15 Jan 2008, 12:07 PM · Views: 1,189

Results 1 to 8 of 8
This thread is locked. New replies are disabled.
15 Jan 2008, 12:07 PM
#1
pickledshark avatar

pickledshark

New Zenner

Join Date:
Nov 2005
Posts:
24
Plugin Contributions:
0

At which stages of checkout is stock checked?

I made a modification to a shop where a product can be set to turn on at a given time and set to turn off at a given time. This is for show tickets so people have a 15 minute window to purchase.

There is also a limited number of these tickets so the stock is all setup to not allow checkout if the stock runs out, which works fine under my testing.

When this situation went live more tickets were sold than there was stock, although the product still went out of stock etc. as expected.

What I believe happened is that there were say 2 products left in stock and 3 people went to checkout at roughly the same time. If they all landed on the paypal page at about the same time and then made payment, would there have been a stock check at that stage?

So my question is, at what stage of the checkout is stock actually checked? It doesn't look like it is being checked when they pay at Paypal (IPN) so is it the final confirmation page of checkout?

15 Jan 2008, 12:56 PM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: At which stages of checkout is stock checked?

I believe that the issue is not checking of stock but more when stock is subtracted.

This is upon successful purchase/payment completion

checkout_success.php

Zen-Venom Get Bitten

15 Jan 2008, 1:07 PM
#3
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: At which stages of checkout is stock checked?

Kobra is right. The issue here is when stock is actually subtracted.

Stock is checked when a product is placed in the shopping basket, but it is checked against what's currently believed to be on the shelf. So three people can be expressing interest in the same item by placing it in their shopping basket, even if there are only two (or even one) items available.

The stock will only be reduced when the order is completed successfully, i.e. when you receive confirmation back from Paypal that the transaction has completed successful (can't happen before because the transaction might not happen due to cart abandonment, can't happen as part of the payment process, as Paypal doesn't have access to your database).

For a site such as yours where people are funnelled to try to buy at the same time, what you really need is a reserving or stock holding, that allows a product to be placed in a cart but then released if the transaction hasn't been completed within a pre-set time frame (5 minutes say). Obviously this would require custom development!

Kuroi Web Design and Development | Twitter

(Questions answered in the forum only - so that any forum member can benefit - not by personal message)

15 Jan 2008, 1:09 PM
#4
pickledshark avatar

pickledshark

New Zenner

Join Date:
Nov 2005
Posts:
24
Plugin Contributions:
0

Re: At which stages of checkout is stock checked?

I believe that the issue is not checking of stock but more when stock is subtracted.

This is upon successful purchase/payment completion

checkout_success.php

Surely it would happen in the ipn_main_handler.php, when paypal calls back and the order is recorded etc.?

What I think is happening is that it is not checking stock at this stage, just subtracting. So in my example the three people all checked out without a problem and the stock ended up -1, even though the stock settings should (and do under normal circumstances) prevent checkout when there is no stock.

Does that make sense?

15 Jan 2008, 1:11 PM
#5
pickledshark avatar

pickledshark

New Zenner

Join Date:
Nov 2005
Posts:
24
Plugin Contributions:
0

Re: At which stages of checkout is stock checked?

kuroi:

For a site such as yours where people are funnelled to try to buy at the same time, what you really need is a reserving or stock holding, that allows a product to be placed in a cart but then released if the transaction hasn't been completed within a pre-set time frame (5 minutes say). Obviously this would require custom development!

What I was thinking is that the stock should be checked when paypal calls back, and if there is not enough stock then cancel the paypal payment and redirect (back to the shopping cart or something with a message). Much better than having a hold/release in the cart, as there might be many time wasters who just add to cart. I would rather get as many people to checkout as possible and have the quickest payer win!

But does anyone know at which stage the last stock check is made?

15 Jan 2008, 1:17 PM
#6
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: At which stages of checkout is stock checked?

I'm not sure whether it's possible to to return to Paypal to cancel an order. However, you could significantly narrow the window for this problem to occur by adding a check to the process that occurs immediately after the confirm checkout button is pressed, so that the transaction is only exposed for the duration of the Paypal transaction.

If you wanted to eliminate the risk altogether but avoid time wasters, this would also be the time to insert a hold, as it would only come into effect for customers committing to the purchase.

Kuroi Web Design and Development | Twitter

(Questions answered in the forum only - so that any forum member can benefit - not by personal message)

15 Jan 2008, 1:22 PM
#7
pickledshark avatar

pickledshark

New Zenner

Join Date:
Nov 2005
Posts:
24
Plugin Contributions:
0

Re: At which stages of checkout is stock checked?

kuroi:

I'm not sure whether it's possible to to return to Paypal to cancel an order. However, you could significantly narrow the window for this problem to occur by adding a check to the process that occurs immediately after the confirm checkout button is pressed, so that the transaction is only exposed for the duration of the Paypal transaction.

That is a great suggestion, thanks for that. I might investigate paypal checking at a later stage but for now checking at the final step should at least reduce it.

Is it the basket where the last check is made do you know? So I can "borrow" some code ;)

15 Jan 2008, 1:34 PM
#8
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: At which stages of checkout is stock checked?

No, I believe that the last check is on the way into the checkout_confirmation page and you'll find easily borrowed code in that page's header file.

I believe (notice my careful choice of verbs) that you will want to add the code, tailored for whatever error handling you want to include, into the header file for checkout_process (the page doesn't actually exist but has a stub header).

Kuroi Web Design and Development | Twitter

(Questions answered in the forum only - so that any forum member can benefit - not by personal message)