Support » Plugin: YITH WooCommerce Brands Add-On » How can you get the Brand onto the Shop pages?

  • simon_a6

    (@simon_a6)


    We are trying to write a function that places the brand under each photo on the shop/archive pages. We are really stuck – trying to learn how to do it, but failing at each hurdle. Can you help?

    There is where we are at:

    // add brand to archive pages
    function bbloomer_show_woocommerce_brands_loop($productBrandTerm) {
        $productBrandTerm = wp_get_post_terms( $post->id, 'product_brand', array("fields" => "name"));
        print_r($post->id);
                 echo '<div>here'.$productBrandName.'</div>';
    }
    add_action( 'woocommerce_after_shop_loop_item_title', 'bbloomer_show_woocommerce_brands_loop', 8 );
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author YITHEMES

    (@yithemes)

    Hello there,
    hope you are doing well! 🙂

    Could you check if you can achieve what you need adding the next code in the functions.php of your active theme?

    function yith_ywbr_show_woocommerce_brands_loop() {
    
        global $product;
    
        $product_brands = get_the_terms( $product->get_id() , 'yith_product_brand');
    
        if ( is_array( $product_brands ) ){
            foreach ($product_brands as $product_brand ){
                echo '<div>' . $product_brand->name . '</div>';
    
            }
        }
    }
    add_action( 'woocommerce_after_shop_loop_item_title', 'yith_ywbr_show_woocommerce_brands_loop' );

    Check it and let us know any news, please.

    Have a nice day!

    It doesn’t product anything at all in the loop.
    I even added “here” after <div> and it didn’t show it.

    Though we are using this to adjust some styling issues:

    //Remove Actions
    remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
    //remove_action( 'woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_title' , 10 );
    remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_rating', 5 );
    remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
    
    //Add Actions
    //add_action('woocommerce_after_shop_loop_item', 'woocommerce_template_loop_product_title', 9);
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How can you get the Brand onto the Shop pages?’ is closed to new replies.