Brands under products - by TheOne - on WordPress WooCommerce support

This topic has 8 replies, 3 voices, and was last updated 5 years, 2 months ago ago by Olga Barlow

  • Avatar: TheOne
    TheOne
    Participant
    September 3, 2019 at 23:38

    Hello,

    Is there a way i can display brands name and not the category name (becouse there are more categories and it gets crowded) bellow the product images on shop/archive page ?

    Thank you,

    7 Answers
    Avatar: Rose Tyler
    Rose Tyler
    Support staff
    September 4, 2019 at 08:07

    Hello,

    You can disable categories from the shop grid via Theme Options > WooCommerce (Shop) > Shop > Products style > Product Content Elements > http://prntscr.com/p1jx2y
    Or you can set “Primary category” that will be shown on the grid – http://prntscr.com/p1jxr2
    To display brands you can add this code in functions.php file of the child theme:

    add_action('woocommerce_after_shop_loop_item_title', 'et_print_brands', 10);
    function et_print_brands(){
        global $post, $product;
        $terms = wp_get_post_terms( $post->ID, 'brand' );
        if(count($terms)>0) {
            ?>
    			<p>Brands: 
                <?php
                    foreach($terms as $brand) {
                        $image          = '';
                        $thumbnail_id   = absint( get_term_meta ( $brand->term_id, 'thumbnail_id', true ) );
                        ?>
                        <a href="<?php echo get_term_link($brand); ?>">
                            <?php
                                echo $brand->name;
                            ?>
                        </a>
                        <?php
                    }
                ?>
                </p>				
            <?php
        }
    }

    Regards

    Avatar: TheOne
    TheOne
    Participant
    September 4, 2019 at 08:45

    Hello,

    Thank you for a quick response! But unfortunately the brand labels are not showing.

    Avatar: Rose Tyler
    Rose Tyler
    Support staff
    September 4, 2019 at 08:51

    Hello,

    Is child theme activated on your site?
    Have you cleared all cache?

    Regards

    Avatar: TheOne
    TheOne
    Participant
    September 4, 2019 at 18:05

    Hello,

    Yes it’s activated and i cleared all the cache. I also tried to put it original functions.php (for test) and it returns -> “The site is experiencing technical difficulties.”

    Avatar: Olga Barlow
    Olga Barlow
    Support staff
    September 4, 2019 at 20:35

    Hello,

    If you got that message it means that some fatal error appeared on your site, probably you missed something in code. What code the original functions.php includes? Provide screenshot.
    Besides, if you go to XStore > Theme Options > WooCommerce > Shop elements > Brand there is option to enable brand on grid/list http://prntscr.com/p1vgxl
    Is not that position suitable for you without that additional code?

    Regards

    Avatar: TheOne
    TheOne
    Participant
    September 5, 2019 at 15:58

    This is beyond stupid on my part… offcourse nothing works if you don’t assign the product to the brand. Rose your code worked perfectly! And Olga i didn’t know you could enable the brands in the theme options. Those two solutions are enough.

    Sorry for the inconvenience

    Avatar: Olga Barlow
    Olga Barlow
    Support staff
    September 5, 2019 at 17:55

    Hello,

    Glad that you sorted out. You are welcome.

    Regards

  • Viewing 8 results - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.Log in/Sign up

8theme customization service
We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.