Home Forums WoodMart support forum Brand label in shop page

Brand label in shop page

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #91209

    leonidas
    Participant

    Hello
    I found somewhere in this forum a way to add a brand icon in the shop page.

    function brands_in_loop(){
    global $product;
    $output = array();
    $product_brands = wp_get_post_terms( $product->get_id(), woodmart_get_opt( ‘brands_attribute’ ) );
    echo ‘<div class=”custom-loop-brands”>’;
    foreach ( $product_brands as $brands ) {
    $image = get_term_meta( $brands->term_id, ‘image’, true );
    if ( $image ) {
    echo ‘<span class=”brand-archive”>slug ) . ‘” alt=”‘ . esc_attr( $brands->slug ) . ‘” /></span>’;
    }else{
    echo ‘<span class=”brand-archive”>’ . $brands->name . ‘</span>’;
    }
    }
    echo ‘</div>’;
    }
    add_action( ‘woocommerce_shop_loop_item_title’, ‘brands_in_loop’, 5 );

    I was wondering if it is possible to modify the code in such a way that when a customer click over the brand icon to redirected in the filters area ( this is happening when I do the same in the quick view popup -check the video)

    Regards Leonidas

    #91245

    Artem Temos
    Keymaster

    Hi,

    Try to replace this line

    echo '<span class="brand-archive"><img src="' . esc_url( $image ) . '" title="' . esc_attr( $brands->slug ) . '" alt="' . esc_attr( $brands->slug ) . '" /></span>';

    with this code

    $link = get_post_type_archive_link( 'product' );
    $filter_name = 'filter_' . sanitize_title( str_replace( 'pa_', '', woodmart_get_opt( 'brands_attribute' ) ) );
    echo '<span class="brand-archive"><a href="' . esc_url( add_query_arg( $filter_name, $brands->slug, $link ) ) . '"><img src="' . esc_url( $image ) . '" title="' . esc_attr( $brands->slug ) . '" alt="' . esc_attr( $brands->slug ) . '" /></a></span>';
    #91276

    leonidas
    Participant

    You can close the ticket.
    Thank you

    #91295

    If you have any questions please feel free to contact us.

    Best Regards

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Brand label in shop page’ is closed to new replies.