WooCommerce: Disable Quantity Change in Cart Page
By Categories: Woocommerce2.1 min read

As a WooCommerce store owner, you might have come across the need to disable the quantity change option on the cart page for various reasons. This could be because you want to control the stock better or provide a more streamlined customer experience. In this blog post, we’ll walk you through the process of disabling the quantity change option in a WooCommerce cart page.

Disabling Quantity Change: A Two-Step Solution

To effectively disable the quantity change option on the cart page, we’ll implement a two-step solution. The first step is to hide the quantity input field using custom CSS, and the second step is to prevent users from changing the quantity by directly manipulating URL parameters.

Hiding the Quantity Input Field with Custom CSS

Add the following CSS code to your theme’s custom CSS section or the style.css file in your child theme:

.woocommerce-cart .quantity {
    display: none !important;

This code will hide the quantity input field on the cart page, making it impossible for customers to alter the quantity of items in their cart.

If this code didn’t work for your theme, go to the cart page and get the table data class. To get that, inspect element on the table heading and table data cell container for the class that has been set.

If you’re having trouble doing these steps, please check out the video tutorial.

Preventing Users from Changing the Quantity via URL Parameters

Add the following code to your theme’s functions.php file:

function disable_quantity_change_in_the_cart( $passed, $cart_item_key, $values, $quantity ) {
    if ( isset( $values['quantity'] ) && $quantity !== $values['quantity'] ) {
        $passed = false;
        wc_add_notice( __( 'Sorry, you cannot change the quantity.', 'woocommerce' ), 'error' );
    return $passed;
add_filter( 'woocommerce_update_cart_validation', 'disable_quantity_change_in_the_cart', 10, 4 );

This code uses the woocommerce_update_cart_validation filter to validate the update process. If the new quantity is different from the old one, it will display an error message and prevent the quantity change.

Wrapping Up

By following these two simple steps, you can effectively disable the quantity change option on your WooCommerce cart page. This will help you maintain better control over your inventory and provide a more streamlined shopping experience for your customers.

Remember that customizing your WooCommerce store to fit your unique needs is crucial for delivering the best customer experience. Don’t be afraid to experiment with different configurations and settings to find the perfect balance for your online store.