• Resolved horgster

    (@horgster)


    Hi @iverok

    At Thursday, we had an huge ticket release to one of our biggest event.
    We sold 112 tickets in 15 minutes.

    Apparently this lead to -1 backorder on some tickets, as multiple persons tried to purchase a product that had only 1 item left in the stock at the same time.

    I am easily able to reproduce this.

    This perhaps an limitation in WooCommerce, but could it be possible to improve the “Order payment process” when using VIPPS Express Checkout and regular VIPPS checkout?

    When the customer starts that paymentprocess, VIPPS should check the current available stock and reserve one item in the stock to avoid other customers perform an backorder to -1. If the customer cancel the payment process or if it fail, VIPPS shall revert the stocknumber.

    Would that be possible?

    Our customers gets quite angry when this happens when we have to cancel their ticket due to backorders.

    Best Regards
    Horgster

    • This topic was modified 3 years ago by horgster.
Viewing 10 replies - 1 through 10 (of 10 total)
  • Thread Starter horgster

    (@horgster)

    Hi @iverok

    You are perhaps busy continuously improving this great plugin ??

    Would be lovely if you had a chance to look at this as we are having an new great ticket drop 1st december.

    Thanks.

    Plugin Author Iver Odin Kvello

    (@iverok)

    I’m sorry; I actually never saw this ticket; thanks for the heads-up!

    Could you describe exactly how you replicate this? I suppose you have a resource with stock level 1, but with two Express Checkout processes going at the same time?

    You are right that this is a limitation of WooCommerce in general – the stock gets reduced when the order is “finalized”, not when it is pending. The issue with the express checkout process is that the order is pending a lot longer than it would be with the regular checkout process.

    Reducing the stock on order creation (and releasing it on order cancel) could work in your case, but I’m not sure if it is a good idea to do as a general rule, because people do press the express checkout button with no real intention to buy, which would cause the stock to be reserved until the order times out.

    You could also in this case try to reserve a small amount of tickets beforehand to avoid the problem to act as a reserve stock (assuming there is a relatively large number of items in the resource).

    I’ll create some code to do the reserve/release on order creation/cancellation, but I will need to test it a bit – I will respond in this ticket when ready.

    Plugin Author Iver Odin Kvello

    (@iverok)

    Ok, so to reserve stock *when creating an express checkout order* and releasing stock when order is cancelled, add this to your childthemes ‘functions.php’:

    add_action('woo_vipps_ajax_do_express_checkout', 'wc_maybe_reduce_stock_levels');

    This is pretty safe; except for the one issue that if the user abandons the order without completing or cancelling the purchase, stock will not be replaced until the order is cancelled, which should normally happen when the process times out. This assumes that the callback for this arrives as it should and is handled by your system as it should.

    There *is* a cleanup action for this running in wp-cron, but it is currently written to find missing *positive* callbacks, and could miss some orders where the *negative* callback didn’t come. We are going to fix this, but I don’t have an exact ETA for that.

    Thread Starter horgster

    (@horgster)

    Hi @iverok

    Thanks for answering quickly and good support as always!

    To repro this is easy, simply do this:

    1. Have one product with stock level 1
    2. Open the product page on two different browsers. I used my PC and my mobile device.
    3. Start the VIPPS Express Checkout process on each device at the same time.
    4. Complete the payment for both orders.
    5. The last device whom completes the payment, will reduce the stock level from 0 to -1

    The solution that you describes above worries me, that the stock easily can get messed-up or ending to be “sold out” easily when you have 100-200 people at the same time trying to fetch an popular ticket. We need to ensure that the stock level is not messed up as you mention as well.

    In this case we also lost 750NOK in VIPPS admin fee since we had to refund an overbooked ticket that had a value of 25.500,-NOK. (yeah you heard right 25k ?? )
    VIPPS do not refund the admin fee of 3% when a product is refunded.

    So there is also an interest here to reduce cost by solving this ??

    The problem occurs also when someone is using the regular VIPPS checkout as well.

    Best Regards
    Horgster

    • This reply was modified 3 years ago by horgster.
    • This reply was modified 3 years ago by horgster.
    • This reply was modified 3 years ago by horgster.
    • This reply was modified 3 years ago by horgster.
    Plugin Author Iver Odin Kvello

    (@iverok)

    The regular Vipps checkout is just the normal Woo checkout, which does a “reserve stock” separate from stock reduction on order creation. However, there is of course a race condition at that point if you have a lot of customers trying to by the same product, so this can fail.

    Otherwise, stock is reduced on payment complete (or equivalent order status) and restored on “cancelled”. Pending orders will be automatically cancelled by Woo after about one hour if left in that state,

    In your case, it may suffice to keep track of “pending” orders and cancel them sooner. For Vipps specifically, we will improve this (by cancelling orders we *know* are abandoned at Vipps) but that is not likely to be ready for your time schedule.

    For this, you may need to either implement the filter as described above, or disable express checkout for the order in question, so that it goes through the normal Woo Checkout process instead. You will probably still need to either reduce the “held stock” time (at /wp-admin/admin.php?page=wc-settings&tab=products&section=inventory) or monitor orders stuck in pending manually, or automate this otherwise.

    I think the safest option is to reserve 1 or 2 items from the stock count in Woo so you can “restock” in the case it ends up at -1.

    You *can* reduce stock on order creation for all Vipps orders (not just express) by using the action ‘woo_vipps_before_redirect_to_vipps’ instead of the action mentioned above. But this shouldn’t be neccessary, will only apply to Vipps orders, and you will still have a race condition in place.

    Thread Starter horgster

    (@horgster)

    Hi @iverok

    Thanks for adding this to the roadmap to improve this, really thankful!
    For; disabling the VIPPS Express Checkout is not an option as this is the best and smoothest way of purchasing and easiest for the end users.

    I think perhaps it is best to wait until you have an final fix so that we can ensure that the stock is not messed up without having to tweaking to much.

    What do you think would be the ETA for this (put your finger up in the air)?

    Plugin Author Iver Odin Kvello

    (@iverok)

    As I mentioned, it can’t really be *fixed* as such if you still get the issue in the normal Checkout screen, which would be a theoretical possibility. But I have updated the Express Checkout order flow now so that it calls more of several hooks that was added after the original implementation; one of which is relevant for stock reserve on order creation. So it should limit the problem, in particular for Express Checkout where this was much more of an issue.

    I’ve also ensured that the job that checks orders stuck in “pending” will cancel abandoned orders; so that issue should be resolved. You should be able to control the time schedule here the normal way with the WooCommerce parameter.

    I think that the safest thing to do is to reserve one item if at all possible.

    As for an ETA: Though this is ready, the code does add a new call to a hook which in principle could cause issues if any plugin does actions that is not compatible with Express Checkout. Therefore, we are probably going to stick with our schedule of releasing this on mondays only so we can be sure to respond quickly to merchants that experience issues. However, you can download the Release branch from github right now (https://github.com/vippsas/vipps-woocommerce).

    Thread Starter horgster

    (@horgster)

    Hi @iverok

    Thanks for your kind assistance and the work to improve this as much as possible!
    I will test how it works and revert.

    Best Regards
    Horgster

    Thread Starter horgster

    (@horgster)

    Hi @iverok

    I have just tested this, and this is so much better both for VIPPS Regular Checkout and Express Checkout. Works as intended! ??

    What is the timeout aka “Hold Stock” for Express Checkout if the user is not responding for payment?

    I was thinking setting nearly the same value in “Hold stock” so that the user gets nearly same user-experience here: admin.php?page=wc-settings&tab=products&section=inventory

    Thanks!

    Best Regards
    Horgster

    Plugin Author Iver Odin Kvello

    (@iverok)

    Excellent news, thank you. The “Hold stock” value is the same for all Woo purchases, which is the one you refer to in the backend.

    It shouldn’t be set too low however; you probably want slow customers to have enough time to complete their purchase. Though I guess credit card solutions will be slower than Vipps.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘VIPPS do not respect do not allow backorders’ is closed to new replies.