Hide multiple product attributes on woocommerce product page

Viewed 101

I would like to hide a second attribute on the woocommerce product page. It works great with this code for one attribute:

function my_attribute_hider ( $attributes ) {
if ( isset( $attributes['pa_attribute-name'] ) ){
    unset( $attributes['pa_attribute-name'] );
}
return $attributes;
}
add_filter( 'woocommerce_get_product_attributes', 'my_attribute_hider' );

How to add a second one?

1 Answers

To use this function for two product attribute, try the following:

function my_attribute_hider ( $attributes ) {
    if ( isset( $attributes['pa_attribute-name'] ) ){
        unset( $attributes['pa_attribute-name'] );
    }
    if ( isset( $attributes['pa_attribute-name2'] ) ){
        unset( $attributes['pa_attribute-name2'] );
    }
    return $attributes;
}
add_filter( 'woocommerce_get_product_attributes', 'my_attribute_hider' );

It should work.

Related