bond007f
Forum Replies Created
-
Forum: Plugins
In reply to: [WooCommerce] Hide Attribute based on CategoryGot it working with the following code
add_action( 'wp', 'remove_product_content' ); function remove_product_content() { // If a product in the 'Cookware' category is being viewed... if ( has_term( array('CHANDEL-AIR', 'CHANDELIER','POT RACK','VANITY','BILLIARD/ISLAND' ), 'product_cat' ) ) { function mycode_hide_attributes_from_additional_info_tabs( $attributes, $product ) { /** * Array of attributes to hide from the Additional Information * tab on single WooCommerce product pages. */ $hidden_attributes = [ 'pa_item-min-length-or-square', ]; foreach ( $hidden_attributes as $hidden_attribute ) { if ( ! isset( $attributes[ $hidden_attribute ] ) ) { continue; } $attribute = $attributes[ $hidden_attribute ]; $attribute->set_visible( false ); } return $attributes; } add_filter( 'woocommerce_product_get_attributes', 'mycode_hide_attributes_from_additional_info_tabs', 20, 2 ); } }
Forum: Plugins
In reply to: [WooCommerce] Hide Attribute based on CategoryI have found the following code to hide an attribute, just need to figure out how to base it on category. Do you have any suggestions?
function mycode_hide_attributes_from_additional_info_tabs( $attributes, $product ) { /** * Array of attributes to hide from the Additional Information * tab on single WooCommerce product pages. */ $hidden_attributes = [ 'pa_item-min-length-or-square', ]; foreach ( $hidden_attributes as $hidden_attribute ) { if ( ! isset( $attributes[ $hidden_attribute ] ) ) { continue; } $attribute = $attributes[ $hidden_attribute ]; $attribute->set_visible( false ); } return $attributes; } add_filter( 'woocommerce_product_get_attributes', 'mycode_hide_attributes_from_additional_info_tabs', 20, 2 );
Forum: Plugins
In reply to: [WooCommerce] Hide Attribute based on Categoryok so I have two images for you. In the first you will find the category Chandelier highlighted in yellow.
https://2ndave.com/capture-4.pngIn the second image you will see that same Chandelier category on top and the attribute Item Min Length or Square: lower down the page highlighted.
https://2ndave.com/capture-5.pngWhat I want to do is set it up when the category is Chandelier Hide the attribute Item Min Length or Square: aka (pa_item-min-length-or-square) because that dimension is not needed for that category. Is this possible with php code put into functions.php
I would send the url, but the site is currently in construction mode and can only be viewed with a login
Forum: Plugins
In reply to: [WooCommerce] Hide Attribute based on CategoryMaybe the remove action code could uncheck the Visible on the product page box on this one attribute somehow