Search code examples
phpwordpresswoocommercecart

Remove Woocommerce cart quantity selector from cart page


I am trying to remove Woocommerce cart quantity selector from the cart page. I am using the quantity input field on my shop archive pages and it has applied it to the cart page. How can I remove it and not allow the user to change it?

I have tried the following with the code below, researched and found from official Woocommerce docs but it is doesnt apply the rule...

function wc_remove_quantity_field_from_cart() {

if ( is_cart() ) return true;

}

add_filter( 'woocommerce_is_sold_individually', 'wc_remove_quantity_field_from_cart', 10, 2 );

Solution

  • You were just missing the $return and $product from your function...The below function will work otherwise with the built in hook.

    function wc_remove_quantity_field_from_cart( $return, $product ) {
    
    if ( is_cart() ) return true;
    
    }
    
    add_filter( 'woocommerce_is_sold_individually', 'wc_remove_quantity_field_from_cart', 10, 2 );