Home Forums WoodMart – Premium Template Display more then one attribute (brands) next to title

This topic contains 6 replies, has 2 voices, and was last updated by Elise Noromit Elise Noromit 1 month ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #234784

    zurich
    Customer

    Hi!
    How do I display more than one brand next to the title on a product archive page?
    For example I have something like attribute hierarchy as country-> region-> sub-region or audi-> 80-> b3
    Now I show it by category, but it doesn’t suit for me because it turns out a very large number of categories, they are difficult to moderate

    Attachments:
    You must be logged in to view attached files.
    #234818

    Hello,

    You can show a label attribute on the product grid. In order to activate the attribute, navigate to Products > Attributes > enter the Brand attribute and enable “Show attribute label on products”.

    Best Regards

    #234823

    zurich
    Customer

    Thank you!
    I want to display attributes instead categories

    Attachments:
    You must be logged in to view attached files.
    #234845

    zurich
    Customer

    I used this snippet but don’t like result
    Maybe you have more elegant solution?

    add_action( ‘woocommerce_after_shop_loop_item’, ‘custom_display_post_meta’, 9 );
    function custom_display_post_meta() {
    global $product;
    $attr = array(‘pa_country’, ‘pa_region’,’pa_village’ );
    foreach ( $attr as $key=>$attribute ) {
    $values = wc_get_product_terms( $product->id, $attribute, array( ‘fields’ => ‘names’ ) );
    if (!empty($values))
    echo ‘<div class=attr_region><span>’. implode( ‘, ‘, $values ).'</span></div>’;
    }
    }

    #234869

    Hello,

    Try these steps:

    1. Enable showing the attribute on the product page. https://prnt.sc/so0wvn

    2. Enable “Show attributes table after short description” in the Theme Settings > Product page > Hide/show elements.

    3. Set the Show summary on hover for Hover on product

    4. Set “Additional information” for the Hover content in the Theme Settings > Shop page > Product Styles and

    Best Regards

    #235059

    zurich
    Customer

    Thank you!

    But it’s not a solution for me, in this case i must change all my products to variable.

    In my case i solve it with this snippet, i leave it here if some one need it.

    function wc_show_attribute_links() {
    	echo '<div class=wrap_attr>';
    	global $post;
    	$attribute_names = array( 'pa_attr_slug1', 'pa_attr_slug2','pa_attr_slug3' ); // attribute array
    		
    	foreach ( $attribute_names as $attribute_name ) {
    		$taxonomy = get_taxonomy( $attribute_name );
    		
    		if ( $taxonomy && ! is_wp_error( $taxonomy ) ) {
    			$terms = wp_get_post_terms( $post->ID, $attribute_name );
    			$terms_array = array();
    		
    	        if ( ! empty( $terms ) ) {
    		        foreach ( $terms as $term ) {
    			       $archive_link = get_term_link( $term->slug, $attribute_name );
    			       $full_line = '<a href="' . $archive_link . '">'. $term->name . '</a>';
    			       array_push( $terms_array, $full_line );
    		        }
    				echo '<div class=attr_name><span>'.implode(  '<bull_>&bull;</bull_>', $terms_array ).'<bull_>&bull;</bull_></span></div>';
    		      
    	        }
        	}
        }
    echo '</div>';}
    
    add_action( 'woocommerce_shop_loop_item_title', 'wc_show_attribute_links' );
    #235139

    Hello,

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

    Best Regards

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

You must be logged in to reply to this topic.