Iin WooCommerce, I set woocommerce-> settings-> products-> inventory-> format for displaying stocks on "Never show the remaining quantity in stock . "
However, if the customer advertises the product in the basket, he continues to move the page or check page and enters a value that is higher than in our warehouse, this error message:
Sorry, we don’t have enough " {product_name}" in stock to complete your order ( {available_stock_amount}in stock). Change your cart and try again. We apologize for any inconvenience this may cause.
What filter can I use to edit this output? I do not want him to show (absolutely anywhere in the store) the real available amount of stock.
I found that this is handled in a function (check_cart_item_stock), in [root] → wp-content-> plugins-> woocommerce-> includes-> class-wc-cart.php on line 491:
if ( ! $product->has_enough_stock( $product_qty_in_cart[ $product->get_stock_managed_by_id() ] ) ) {
$error->add( 'out-of-stock', sprintf( __( 'Sorry, we do not have enough "%1$s" in stock to fulfill your order (%2$s in stock). Please edit your cart and try again. We apologize for any inconvenience caused.', 'woocommerce' ), $product->get_name(), wc_format_stock_quantity_for_display( $product->get_stock_quantity(), $product ) ) );
return $error;
}
So, I want to filter out the " (%2$s in stock)" part . But I can not find a filter for this.
source
share