Hi. How can we help?

How to insert the header image that appears in the vendor page even in single product page

You can insert header image in the vendor page if you add this code in your functions.php:

if( function_exists( 'YITH_Vendors' ) ){
add_action( 'init', 'yith_wcmv_add_store_header_in_single_product_page', 20 );

function yith_wcmv_add_store_header_in_single_product_page(){
add_action( 'woocommerce_before_single_product_summary', 'yith_wcmv_add_store_header_page', 5 );
}

function yith_wcmv_add_store_header_page(){
global $product;
$vendor = yith_get_vendor( $product, 'product' );

if ( $vendor->is_valid() ) {
global $sitepress;
$has_wpml = ! empty( $sitepress );
$term = $default_term = null;
$term_slug = get_query_var( 'term' );
if( $has_wpml ){
$term = get_term_by( 'slug', $term_slug, YITH_Vendors()->get_taxonomy_name() );
$term_slug = yit_wpml_object_id( $term->term_id, YITH_Vendors()->get_taxonomy_name(), true, wpml_get_default_language() );
$default_term = get_term( $term_slug, YITH_Vendors()->get_taxonomy_name() );
}

if ( 'no' == $vendor->enable_selling ) {
return false;
}

$header_img_class = apply_filters( 'yith_wcmv_header_img_class', array( 'class' => 'store-image' ) );

$args = array(
'vendor' => $vendor,
'name' => $has_wpml ? $default_term->name : $vendor->name,
'header_skin' => get_option( 'yith_vendors_skin_header', 'small-box' ),
'show_total_sales' => 'yes' == get_option( 'yith_wpv_vendor_total_sales' ) ? true : false,
'icons' => apply_filters( 'yith_wcmv_header_icons_class', array(
'rating' => 'fa fa-star-half-o',
'sales' => 'fa fa-credit-card',
'vat' => 'fa fa-file-text-o',
'legal_notes' => 'fa fa-gavel',
)
),
'owner' => get_user_by( 'id', $vendor->owner ),
'header_image_html' => get_option( 'yith_vendors_skin_hmtl_header_image_format', 'image' ),
'header_img_class' => $header_img_class,
'header_image' => wp_get_attachment_image( $vendor->header_image, 'big', false, $header_img_class ),
'owner_avatar' => get_avatar( $vendor->owner, get_option( 'yith_vendors_gravatar_image_size', '62' ) ),
'vendor_reviews' => $vendor->get_reviews_average_and_product(),
'total_sales' => count( $vendor->get_orders( 'suborder' ) ),
'store_header_class' => apply_filters( 'yith_wcmv_store_header_class', 'store-header-wrapper' ),
'show_vendor_vat' => 'yes' === get_option( 'yith_wpv_vendor_show_vendor_vat', 'yes' ) ? true : false,
'show_gravatar' => 'enabled' == get_option( 'yith_vendors_show_gravatar_image', 'enabled' ) && 'yes' == $vendor->show_gravatar,
'socials_list' => YITH_Vendors()->get_social_fields(),
);

do_action( 'yith_wcmv_before_vendor_header', $args, $vendor );
yith_wcpv_get_template( 'store-header', $args, 'woocommerce/loop' );

/* Vacation Module */
if( $vendor->is_on_vacation() ){
yith_wcpv_get_template( 'store-vacation', array( 'vacation_message' => $vendor->vacation_message ), 'woocommerce/loop' );
}

/* Vendor Description */
$vendor_description = $has_wpml ? $default_term->description : $vendor->description;
if( 'yes' == get_option( 'yith_wpv_vendor_store_description', 'no' ) && ! empty( $vendor_description ) ){
$args = array(
'store_description_class' => apply_filters( 'yith_wcmv_store_descritpion_class', 'store-description-wrapper' ),
'vendor_description' => $vendor_description
);
yith_wcpv_get_template( 'store-description', $args, 'woocommerce/loop' );
}
do_action( 'yith_wcmv_after_vendor_header', $args, $vendor );
}
}
}
Was this article helpful?
1 out of 2 found this helpful

Back to Help Center >