On form-pay, do not check for stock if not managing stock or allowing backorders.

This commit is contained in:
Gerhard 2018-11-07 08:54:41 -05:00
parent 452e8bc065
commit aabae5d21f
1 changed files with 5 additions and 0 deletions

View File

@ -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() ];