phpcsswoocommerceproductadmin

How to hide specific fields from WooCommerce Admin Products Quick Edit


I'm trying to hide some WooCommerce fields from the "Quick Edit" window: "Date", "Tax status", "Tax class", "Weight", "L/W/H", "Shipping class", "Backorders?" and "Enable reviews" fields.

These are the fields I'll want to hide from the "Quick Edit" window:

Quick Edit" window

I have tried to add a "display: none;" property, but I can't figure out to which elements to apply it and how to apply it, since I would like to hide only the fields in red.

I'm using WooCommerce v9.1.2


Solution

  • Updated

    You can use CSS :has() pseudo-class to selects elements that contain other elements.

    Then we use display:none !important to hide those elements.

    Try the following that will hide specific fields in Product Quick Edit:

    // CSS
    add_action( 'woocommerce_product_quick_edit_start',  'hide_specific_product_quick_edit_fields_css' );
    function hide_specific_product_quick_edit_fields_css() {
        // Hide weight, dimensions, backorder, Password, Tax status, Tax class, Shipping class and Enable reviews fields
        ?><style>
        .inline-edit-date, .dimension_fields, .backorder_field, 
        div:has(> label > span > input.inline-edit-password-input),
        label:has(> span > select[name=_tax_status]), 
        label:has(> span > select[name=_tax_class]),
        div:has(> span > select[name=_shipping_class]), 
        div:has(> label > input[name=comment_status]) {display:none !important;}
        </style><?php 
    }
    

    Code goes in functions.php file of your child theme (or in a plugin). Tested and work.