Delete local attributes instead of global attributes
-
Hi,
I made a mistake by importing attributes the wrong way, this is resulting in wrong attributes for a lot of products
The attributes that i added are imported as local custom attributes on each product (so not global attributes as seen in the backend -> Products -> Attributes)
Is there a way to bulk delete these local attributes for all products? For now i hide them on front-end with this code but this is a quick fix.
/** * 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 = [ 'nameofmyattributethatswork', ]; 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 );
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Delete local attributes instead of global attributes’ is closed to new replies.