DrMTR
DrMTR

Reputation: 509

Remove "Weight" from admin product settings and single product page in WooCommerce

I work on small business site, and have a hard time to remove weight from product backend, and also from single product page into "Additional Informations" page. I tryed all "working" solutions that I found on web like Remove product dimensions from single product pages in Woocommerce answer code and this code too:

add_filter( 'woocommerce_product_get_weight' , '__return_false' );

But it seems like that not makes any changes. For better to explain what I need to remove:

enter image description here

enter image description here

Tryed also with CSS:

.tabs-layout-tabs #tab-additional_information .shop_attributes
{
display:none;
}

But this remove all data from the tab. Any help?

Upvotes: 0

Views: 1313

Answers (1)

LoicTheAztec
LoicTheAztec

Reputation: 254212

The following will hide weight field from product backend shipping setting section:

add_action( 'woocommerce_product_options_general_product_data', 'hide_weight_field_from_product_shipping_setting_section', 100 );
function hide_weight_field_from_product_shipping_setting_section() {
    ?>
    <style>
    p.form-field._weight_field  {
        display:none;
    }
    </style>
    <?php
}

Now for frontend single product pages, the code below (like in your question) works on last WooCommerce version, removing weight row from "Additional information" tab:

add_filter( 'woocommerce_product_get_weight' , '__return_false' );

Code goes in functions.php file of your active child theme (or active theme). Tested and works.

Upvotes: 1

Related Questions