Help Modifying WooCommerce Brands Plugin to Hide Brands on Product Pages
-
Before anyone suggests going to WooCommerce for assistance with their plugin (https://woocommerce.com/products/brands/?aff=10486&cid=1131038), I already have and they are not willing to provide help with what REALLY IS a minor modification.
I don’t see anyway to hide the display of the brands on the single product page. We want to tie our products to brands and manage the brands in the admin ONLY for reporting purposes, but we do not want to display brand info on the single product or product archive pages. There is no way to hide this using CSS as it shares the same CSS class as the products categories.
I found the code that contains the target HTML I am after:
class-wc-brands.phpIn this file on lines 336-354 (see code below) I want to make the following change:
Replace: <span class=”posted_in”>
With: <span class=”brands_wrapper”>This minor change will allow me to very simply hide the brands from displaying on the product pages using CSS. I know I can edit this file directly, but I also know it’s a bad practice to modify plugin files like this. Hoping I can get help creating a code snippet to override this part of the plugin so that I do not have to make this change again at every update.
/** * show_brand function. * * @access public * @return void */ public function show_brand() { global $post; if ( is_singular( 'product' ) ) { $terms = get_the_terms( $post->ID, 'product_brand' ); $brand_count = is_array( $terms ) ? sizeof( $terms ) : 0; $taxonomy = get_taxonomy( 'product_brand' ); $labels = $taxonomy->labels; echo get_brands( $post->ID, ', ', ' <span class="posted_in">' . sprintf( _n( '%1$s: ', '%2$s: ', $brand_count ), $labels->singular_name, $labels->name ), '</span>' ); } }
The page I need help with: [log in to see the link]
- The topic ‘Help Modifying WooCommerce Brands Plugin to Hide Brands on Product Pages’ is closed to new replies.