Last active
April 14, 2021 14:32
-
-
Save EricBusch/6fbedaa152fee7a5fe180ad70e65334e to your computer and use it in GitHub Desktop.
Hide specific attributes from the Additional Information tab on single WooCommerce product pages. [datafeedr][woocommerce]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Hide specific attributes from the Additional Information tab on single | |
* WooCommerce product pages. | |
* | |
* @param WC_Product_Attribute[] $attributes Array of WC_Product_Attribute objects keyed with attribute slugs. | |
* @param WC_Product $product | |
* | |
* @return WC_Product_Attribute[] | |
*/ | |
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_network', | |
'pa_merchant', | |
'pa_brand', | |
]; | |
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 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment