• Resolved RebeccaBlackman

    (@rebeccablackman)


    Hi Mike,

    Recently, my customers have been unable to pay for a pending order if an item in that order is out-of-stock. They now receive the following message when attempting to make payment:

    “Sorry, “product” is no longer in stock so this order cannot be paid for. We apologise for any inconvenience caused.”

    Due to how my business works, I need this to be able to work as it did before. Can you help?

    Kind regards,

    Rebecca

Viewing 5 replies - 1 through 5 (of 5 total)
  • You can allow backorders, which will keep the product purchasable even without stock.

    You can also use the in stock filter woocommerce_product_is_in_stock to keep the product in stock when the customer is on the Pay page or needed times.

    Thread Starter RebeccaBlackman

    (@rebeccablackman)

    Hi Vankaa,

    I tried enabling back-orders, but then the item shows as available for other customers to buy. I only want customers with a pending order (that I have created for them) to be able to purchase the items.

    I don’t want to hide the items from my catalogue, as I need people to be able to see them.

    I’m not sure how woocommerce_product_is_in_stock works, but it sounds like it will create the same dilemma above, yes?

    I did find the following code in class-wc-shortcode-checkout.php – would it be safe for me to simply remove it?

    				// Ensure order items are still stocked.
    				foreach ( $order->get_items() as $item_key => $item ) {
    					if ( $item && is_callable( array( $item, 'get_product' ) ) ) {
    						$product = $item->get_product();
    						if ( $product && ! $product->is_in_stock() ) {
    							/* translators: %s: product name */
    							throw new Exception( sprintf( __( 'Sorry, "%s" is no longer in stock so this order cannot be paid for. We apologize for any inconvenience caused.', 'woocommerce' ), $product->get_name() ) );
    						}
    					}
    				}

    Kind regards,

    Rebecca

    I would not recommend removing core code. Instead go the filter route and instead of always adjusting in stock status, do so on the Pay page, where this error message is actually checked and displayed.

    To answer your question, though, yes, if you remove this part behavior will be the same as it was in previous version.

    We haven’t heard back from you in a while, so I’m going to mark this as resolved. If you have any further questions, you can start a new thread.

    @rebeccablackman, I ran into this exact same problem and developed a simple fix for it that uses the ‘woocommerce_product_is_in_stock’ hook (like @vankaa mentioned). Here it is…
    https://wpforthewin.com/woocommerce-cant-pay-out-of-stock-error/

    I hope you and others with the same problem find it helpful.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Out-of-stock items – can’t make payment any more.’ is closed to new replies.