Display Product vendors name

This topic contains 6 reply and 2 voices, and was last updated by towhid 8 years, 10 months ago
Viewing 6 Posts - 1 through 6 (of 6 total)
Author Posts
June 10, 2015 at 9:46 pm 51721
towhid Hi! I want to display the vendors name alongside the Product name and price in the shop page (the thumbnails of products). I found this (pasted below) from woocommerce but i’m guessing the tag for vendors is wrong. Could you help? /** * Print the product’s vendor name before the product title in the loop. * * @return void */ function wc_vendors_name_loop() { $vendors = get_the_terms( get_the_ID(), ‘shop_vendor’ ); if ( $vendors && ! is_wp_error( $vendors ) ) { foreach ( $vendors as $vendor ) { $all_vendors[] = $vendor->name; } $vendors = join( “, “, $all_vendors ); echo ‘‘ . $vendors . ‘‘; } } add_action( ‘woocommerce_before_shop_loop_item_title’, ‘wc_vendors_name_loop’, 20 );
June 11, 2015 at 5:13 pm 51781
towhid towhid

Hello Anna,

Did you try above code? Did you get any error? Can you please let me know the name of the theme you are using for your site now

Thanks

June 11, 2015 at 5:37 pm 51784
Anna Anna

Hi!

I tried it and i got no error. I’m using the dokan theme 🙂

June 11, 2015 at 6:10 pm 51794
towhid towhid

Hello Anna,

I need to test this code for me. Please allow me some time.

Thanks

June 13, 2015 at 5:58 pm 51997
towhid towhid

Hello Anna,

Please navigate to `plugins/woocommerce/templates/single-product/content-product.php and this line
do_action( 'woocommerce_after_shop_loop_item_title' );

After that line paste below code.

global $product;

			$author     = get_user_by( 'id', $product->post->post_author );
	    	$store_info = dokan_get_store_info( $author->ID );
			if ( !empty( $store_info['store_name'] ) ) { ?>
	            <span class="details">
	                <?php echo $store_info['price']; ?>
	                <?php echo $store_info['store_name']; ?>
	            </span>
	        <?php  }

Thanks

June 22, 2015 at 8:18 pm 52725
Anna Anna

Thanks, that worked like a charm! 🙂

Is there a way to get the Vendor name to link to their shop as well?

Thanks!

June 23, 2015 at 12:48 pm 52796
towhid towhid

Hello Anna,

Then, you have to try this following code instead of the previous code which I have given to you.

global $product;

		$author     = get_user_by( 'id', $product->post->post_author );
    	$store_info = dokan_get_store_info( $author->ID );
		if ( !empty( $store_info['store_name'] ) ) { ?>
                <span class="details">
                	<?php echo $store_info['price']; ?>
                    <?php printf( '<a href="%s">%s</a>', dokan_get_store_url( $author->ID ), $author->display_name ); ?>
                </span>
 		<?php } ?>

Please let me know the result when done

Thanks

Viewing 6 Posts - 1 through 6 (of 6 total)