From aabae5d21fa67fc314398f8d0ab47e3cdbf033d0 Mon Sep 17 00:00:00 2001 From: Gerhard Date: Wed, 7 Nov 2018 08:54:41 -0500 Subject: [PATCH] On form-pay, do not check for stock if not managing stock or allowing backorders. --- includes/shortcodes/class-wc-shortcode-checkout.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/includes/shortcodes/class-wc-shortcode-checkout.php b/includes/shortcodes/class-wc-shortcode-checkout.php index 7305eb6f1dd..0ec68b3510b 100644 --- a/includes/shortcodes/class-wc-shortcode-checkout.php +++ b/includes/shortcodes/class-wc-shortcode-checkout.php @@ -143,6 +143,11 @@ class WC_Shortcode_Checkout { 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() ) ); } + // We only need to check products managing stock, with a limited stock qty. + if ( ! $product->managing_stock() || $product->backorders_allowed() ) { + continue; + } + // Check stock based on all items in the cart and consider any held stock within pending orders. $held_stock = wc_get_held_stock_quantity( $product, $order->get_id() ); $required_stock = $quantities[ $product->get_stock_managed_by_id() ];