How to Hide Qty Fields From Cart Page In Woocommerce

Hi Friends, Do you have a Woocommerce website? Today I will share with you a complete guide on How to Hide Qty Fields From Cart Page In Woocommerce.

Why do I use it?

When you have a customized website in WordPress then you have some problems managing your website. When you add a product on their cart with minimum value validation. He/she can change qty on the cart page. Many people facing the same problem with a woo-commerce website.

Now, this function will help you to fix this problem.

Hide Qty Fields From Cart Page In Woocommerce

Here is the code to make readonly qty selector from the cart page. You have to add this code into your theme FUNCTION.php file.

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;
}

How to Edit Function.php file

You have to follow the given step to edit the function.php file in WordPress.

  • Open WordPress Dashboard
  • Go to Appearance on the left-hand side of your screen and click on Theme Editor

hide qty Fields from cart page

  • Find the function.php file and Add the Above code to this file.

Edit Function file

  • Click on the update file button. Now Qty option will be read-only on the cart page. Let’s check it.

Do you Want to buy Web Hosting?

https://angelwebgroup.com/wordpress-user-roles/

https://angelwebgroup.com/how-to-install-wordpress-in-cpanel/

Leave a Comment

Share via
Copy link
Powered by Social Snap