Add filter woocommerce_cart_has_enough_stock_for_product in WC_Cart::check_cart_item_stock method

This commit is contained in:
Fitim 2020-04-16 12:16:11 +02:00
parent 2cadb6b511
commit c28c8e6472
1 changed files with 1 additions and 1 deletions

View File

@ -786,7 +786,7 @@ class WC_Cart extends WC_Legacy_Cart {
$held_stock = wc_get_held_stock_quantity( $product, $current_session_order_id );
$required_stock = $product_qty_in_cart[ $product->get_stock_managed_by_id() ];
if ( $product->get_stock_quantity() < ( $held_stock + $required_stock ) ) {
if ( ! apply_filters( 'woocommerce_cart_has_enough_stock_for_product', $product->get_stock_quantity() >= ( $held_stock + $required_stock ), $product, $values ) ) {
/* translators: 1: product name 2: quantity in stock */
$error->add( 'out-of-stock', sprintf( __( 'Sorry, we do not have enough "%1$s" in stock to fulfill your order (%2$s available). We apologize for any inconvenience caused.', 'woocommerce' ), $product->get_name(), wc_format_stock_quantity_for_display( $product->get_stock_quantity() - $held_stock, $product ) ) );
return $error;