• Resolved thecontaineraffair

    (@thecontaineraffair)


    when you add an item in cart and this has only 1 in stock, and a customer tried to add 2 or 3 or any number in the cart quantity field, an error message – “You must enter a value between 0 and 1 appears”, how can this be customized

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Laurena Rehbein

    (@lrehbein)

    Automattic Happiness Engineer

    Hi @thecontaineraffair,

    You can customize this text with a filter:

    
    /**
     * Change the "You cannot add that amount to the cart" message when customer attempts to purchase more than is in stock
     *
     */
    
    function lar_text_strings( $translated_text, $text, $domain ) {
    	switch ( $translated_text ) {
    		case 'You cannot add that amount to the cart — we have %1$s in stock and you already have %2$s in your cart.' :
    			$translated_text = __( 'new text here', 'woocommerce' );
    			break;
    	}
    	return $translated_text;
    }
    add_filter( 'gettext', 'lar_text_strings', 20, 3 );
    

    You can either add this to your child theme’s function.php file, or add it with a plugin like Code Snippets.

Viewing 1 replies (of 1 total)
  • The topic ‘Cart Stock Error Message’ is closed to new replies.