Stock checks not required if stock levels have already been reduced. (#33575)

* Stock checks not required if stock levels have already been reduced.

* Changelog.
This commit is contained in:
Barry Hughes 2022-09-15 13:57:22 -07:00 committed by GitHub
parent 45559775c9
commit cd31ec0dd5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 20 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
Customers should be able to pay for orders so long as any required stock reductions have already taken place.

View File

@ -138,6 +138,8 @@ class WC_Shortcode_Checkout {
}
}
// Stock levels may already have been adjusted for this order (in which case we don't need to worry about checking for low stock).
if ( ! $order->get_data_store()->get_stock_reduced( $order->get_id() ) ) {
foreach ( $order->get_items() as $item_key => $item ) {
if ( $item && is_callable( array( $item, 'get_product' ) ) ) {
$product = $item->get_product();
@ -167,6 +169,7 @@ class WC_Shortcode_Checkout {
}
}
}
}
WC()->customer->set_props(
array(