• Resolved fletsch

    (@fletsch)


    Hi there

    First I want to thank you for this great and free plugin! ??

    And second a short question. How can I show the brand name on the product page? I’d like to show it in a possition close to the brand logo or the product name. Found this code for showing the description but I couldn’t change it to show the brand name. Can anyone help me out?

    add_action( 'woocommerce_single_product_summary' , 'woocommerce_brand_summary', 25 );
    
    /**
     * woocommerce_brand_summary
     *
     * @access      public
     * @since       1.0 
     * @return      void
    */
    function woocommerce_brand_summary() {
    	
    	global $post;
    	
    	$brands = wp_get_post_terms( $post->ID, 'product_brand', array("fields" => "all") );
    
    	foreach( $brands as $brand ) {
    		echo __( 'Brand Description', '') . ': ' . term_description( $brand->term_id, 'product_brand' );
    	}
    	
    }

    Thanks in advance.

    Best,
    Fletsch

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author quadlayers

    (@quadlayers)

    hello @fletsch

    you can check the woocommerce actions list to include that function

    https://docs.woocommerce.com/document/introduction-to-hooks-actions-and-filters/

    Thread Starter fletsch

    (@fletsch)

    Hi all

    Here’s a solution I built with codes from other support tickets.

    // ADD BRAND NAME TO PRODUCT TITLE ON PRODUCT PAGE
    remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
    add_action( 'woocommerce_single_product_summary', 'aq_display_brand_before_title', 5 );
    function aq_display_brand_before_title(){
    global $product;
    $product_id = $product->get_id();
    $brands = wp_get_post_terms( $product_id, 'pwb-brand' );
    foreach( $brands as $brand ) {
    echo '<h1 class=”product_title entry-title”>';
    if( $brand->name ){
    echo  $brand->name;}
    echo ' ';
    the_title();
    echo '</h1>';
    }
    }

    @fletsch

    Very nice, thanks for the code !

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Show brand name on product page’ is closed to new replies.