1. Home
  2. WC Vendors Pro
  3. Code Snippets
  4. Show Vendor Icon on Single Product Pages

Show Vendor Icon on Single Product Pages

If you would like to show the store icon on the product pages then you will need to add the following code to your themes function.php.

Note: If you want to change it to a different location, change the filter from woocommerce_after_add_to_cart_form to somewhere else.

function wcv_custom_show_icon() {

	if ( WCV_Vendors::is_vendor_page() ) { 

		$vendor_shop 		= urldecode( get_query_var( 'vendor_shop' ) );
		$vendor_id   		= WCV_Vendors::get_vendor_id( $vendor_shop ); 

			$store_icon_src         = wp_get_attachment_image_src( get_post_meta( $store_id, '_wcv_store_icon_id', true ), array( 150, 150  ) );
			$store_icon             = '';
	    // see if the array is valid
	    if ( is_array( $store_icon_src ) ) {
	            $store_icon     = '<img src="'. $store_icon_src[0].'" alt="" class="store-icon" style="max-width:100%;" />';
	    }

	    echo $store_icon; // You might wrap this in some HTML or something depending on your layout.

	} 
}

add_action( 'woocommerce_after_add_to_cart_form', 'wcv_custom_show_icon' );

 

actions

Updated on October 17, 2016

Was this article helpful?