Home / Admin / Change the sold by link label to vendor’s name
Duplicate Snippet

Embed Snippet on Your Site

Change the sold by link label to vendor’s name

Change the sold by link label to vendor's name

Code Preview
php
<?php
if ( ! function_exists( 'display_solby_as_first_name' ) ) {
	/**
	 * Display sold by as vendor first name.
	 *
	 * @param string $soldby the link with name.
	 * @param int    $vendor_id the Vendor ID.
	 */
	function display_solby_as_first_name( $soldby, $vendor_id ) {
		if ( ! WCV_Vendors::is_vendor( $vendor_id ) ) {
			return $soldby;
		}
		$user_data = get_userdata( $vendor_id );
		if ( empty( $user_data->first_name ) ) {
			return $soldby;
		}
		$soldby = sprintf( '<a href="%s">%s</a>', WCV_Vendors::get_vendor_shop_page( $vendor_id ), esc_html( $user_data->first_name ) );
		return $soldby;
	}
	add_filter( 'wcvendors_sold_by_link', 'display_solby_as_first_name', 10, 2 );
}

Comments

Add a Comment