• Resolved guardiano78

    (@guardiano78)


    Hello,
    I have to replace the product title with the product sku on the cart page when the quantity of the product is not enough.
    In class-wc-cart.php at line 789 i found the code to customize:

    if ( apply_filters( 'woocommerce_cart_item_required_stock_is_not_enough', $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;
    			}

    Serching on google, I found this hook:

    function filter_woocommerce_cart_product_not_enough_stock_already_in_cart_message( $message, $product_data, $stock_quantity, $stock_quantity_in_cart ) {
        // New message
        $message = __( 'You are currently trying to order more of this product than are currently available at your shipping location. Please call our sales team to discuss availability', 'woocommerce' );
        
        return $message;
    }
    add_filter( 'woocommerce_cart_product_not_enough_stock_already_in_cart_message', 'filter_woocommerce_cart_product_not_enough_stock_already_in_cart_message', 10, 4 );

    but it doesn’t work.
    Anyone knows hot to do it?
    thanks.

Viewing 16 replies (of 16 total)
Viewing 16 replies (of 16 total)
  • The topic ‘Replace product title with product sku’ is closed to new replies.