• Resolved stephenmcaleer

    (@stephenmcaleer)


    Is there a way you can remove the ability to adjust the quantity when viewing your cart/basket? All I want it the quantity displayed.

    I’m aware of the following but It displays “1” only. I still want quantity displayed.

    function wc_remove_all_quantity_fields( $return, $product ) {
        return true;
    }
    add_filter( 'woocommerce_is_sold_individually', 'wc_remove_all_quantity_fields', 10, 2 );
Viewing 4 replies - 1 through 4 (of 4 total)
  • Rynald0s

    (@rynald0s)

    Automattic Happiness Engineer

    Hi, @stephenmcaleer!

    I apologize, but I’m not really clear on what exactly you need here ..

    Are you saying that you want the selectors itself removed from the cart table qty input, or the selectors AND input field or just the input field .. ?

    Cheers!

    Thread Starter stephenmcaleer

    (@stephenmcaleer)

    Hi @rynald0s, thanks for getting back to me.

    I want selectors and input field remove. All I want is plain text displaying the quantity. Same as price and total. No way of adjusting it inside the cart.

    Thanks

    Rynald0s

    (@rynald0s)

    Automattic Happiness Engineer

    Hi, @stephenmcaleer!

    Ah, it looks like the code there prevents additional qty of the same product to be added to the cart

    See if this works for you:

    add_filter( 'woocommerce_cart_item_quantity', 'wc_cart_item_quantity', 10, 3 );
    function wc_cart_item_quantity( $product_quantity, $cart_item_key, $cart_item ){
        if( is_cart() ){
            $product_quantity = sprintf( '%2$s <input type="hidden" name="cart[%1$s][qty]" value="%2$s" />', $cart_item_key, $cart_item['quantity'] );
        }
        return $product_quantity;
    }

    Cheers!

    Thread Starter stephenmcaleer

    (@stephenmcaleer)

    That Worked!

    Many thanks for your help @rynald0s

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Remove ability to adjust quantity in cart’ is closed to new replies.