简体   繁体   中英

How to remove quantity from cart page in WooCommerce

I want to remove quantity from cart table.. without CSS.

Here is the price, but I want to remove quantity

You can copy woocommerce/templates/cart/cart.php to your themes folder under your-theme/woocommerce/cart/cart.php

In this file, you can remove "Price" column. You can search for 'class="product-price"' and remove that whole ''. You will need to remove respective header as well.

This would help you in case the quantity field isn't needed and you want to use it without CSS and you don't want to change the code of many files of your theme. This will remove the quantity from the following pages.

  • Single Product Page
  • Cart Page
  • Product Archive Page

Add this code to functions.php of your theme to remove the quantity field for all products.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM