hi @jamie
we were half through getting some code adjusted with Ben, but i think there wasnt support within the wc vendors core at the time.
so we should try again now theres been updates.
task is as follows.
1. Only show ‘sold by’ on vendor products and in all vendor loops, emails, products etc.
or
2. Remove ‘sold by’ for admin listed products only, in all loops.
heres the code Ben gave previously (below); we have tried adding it after the code mentioned here and it just creates a error so has to be removed, iv tried and tried
so we have all the remove actions and filters in place in the child theme functions.php, so i guess now the code needs adjusting so its only applicable to the vendor and not admin listings.
hoping you can help @jamie many thanks vadmin 🙂
`add_action( ‘woocommerce_after_shop_loop_item’, ‘custom_template_loop_sold_by’, 9 );
function custom_template_loop_sold_by($product_id) {
$vendor_id = WCV_Vendors::get_vendor_from_product( $product_id );
if ( $vendor_id != ‘3,524’ ) { // Change “1” to the admins user id #
$sold_by = WCV_Vendors::is_vendor( $vendor_id )
? sprintf( ‘%s‘, WCV_Vendors::get_vendor_shop_page( $vendor_id ), WCV_Vendors::get_vendor_sold_by( $vendor_id ) )
: get_bloginfo( ‘name’ );
echo ‘<small class=”wcvendors_sold_by_in_loop”>’ . apply_filters(‘wcvendors_sold_by_in_loop’, __( ‘Sold by: ‘, ‘wcvendors’ )). $sold_by . ‘</small> <br />’;
}
}
add_filter( ‘woocommerce_get_item_data’, ‘custom_sold_by’, 10, 2 );
add_action( ‘woocommerce_product_meta_start’, ‘custom_sold_by_meta’, 10, 2 );
function custom_sold_by( $values, $cart_item )
{
$vendor_id = $cart_item[ ‘data’ ]->post->post_author;
if ( $vendor_id != ‘3,524’ ) { // Change “1” to the admins user id #
$sold_by = WCV_Vendors::is_vendor( $vendor_id )
? sprintf( ‘%s‘, WCV_Vendors::get_vendor_shop_page( $vendor_id ), WCV_Vendors::get_vendor_sold_by( $vendor_id ) )
: get_bloginfo( ‘name’ );
$values[ ] = array(
‘name’ => apply_filters(‘wcvendors_cart_sold_by’, __( ‘Sold by’, ‘wcvendors’ )),
‘display’ => $sold_by,
);
return $values;
}
}
function custom_sold_by_meta()
{
$vendor_id = get_the_author_meta( ‘ID’ );
if ( $vendor_id != ‘3,524’ ) { // Change “1” to the admins user id #
$sold_by = WCV_Vendors::is_vendor( $vendor_id )
? sprintf( ‘%s‘, WCV_Vendors::get_vendor_shop_page( $vendor_id ), WCV_Vendors::get_vendor_sold_by( $vendor_id ) )
: get_bloginfo( ‘name’ );
echo apply_filters(‘wcvendors_cart_sold_by_meta’, __( ‘Sold by: ‘, ‘wcvendors’ )) . $sold_by . ‘<br/>’;
}
}’