• Resolved dutuka

    (@dutuka)


    Hello, i use this code snippet to hide some specific option fields in admin product settings:

    add_filter( 'product_type_options', function( $options ) {
    
        // remove "Virtual" checkbox
        if( isset( $options[ 'virtual' ] ) ) {
            unset( $options[ 'virtual' ] );
        }
        // remove "Downloadable" checkbox
        if( isset( $options[ 'downloadable' ] ) ) {
            unset( $options[ 'downloadable' ] );
        }
            // remove "Downloadable" checkbox
        if( isset( $options[ 'service' ] ) ) {
            unset( $options[ 'service' ] );
        }
                // remove "Downloadable" checkbox
        if( isset( $options[ 'used_good' ] ) ) {
            unset( $options[ 'used_good' ] );
        }  
                // remove "Downloadable" checkbox
        if( isset( $options[ 'defective_copy' ] ) ) {
            unset( $options[ 'defective_copy' ] );
        }
                    // remove "Downloadable" checkbox
        if( isset( $options[ 'differential_taxation' ] ) ) {
            unset( $options[ 'differential_taxation' ] );
        }
                    // remove "Food" checkbox
        if( isset( $options[ 'is_food' ] ) ) {
            unset( $options[ 'is_food' ] );
        }
    
        return $options;
    
    } );

    However this snippet only affects single product, i also want to unset those fields for variation options fields.

    I want to unset these fields.

    And all the lines from the dropdown menu except the top 3 lines.

    How can i achiev that? Any help would greatly appreciated.

    I tried this snippet from here: Hide weight and dimensions fields from product variations settings in Woocommerce

    // Variations
    add_action( 'woocommerce_variation_options_pricing', 'hide_variation_weight_and_dimentions', 10, 3 );
    function hide_variation_weight_and_dimentions( $loop, $variation_data, $variation ){
        ?><style>
            .variable_weight<?php echo $loop ?>_field, .dimensions_field { display:none !important;}
        </style><?php
    }

    But it works only partial, i can not target the lines in dropdown menu and shipping class.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Hide/unset product variation option fields woocomerce settings’ is closed to new replies.