Skip to content

Instantly share code, notes, and snippets.

@bentasm1
Last active October 11, 2015 23:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bentasm1/9573f5124f8c47931eda to your computer and use it in GitHub Desktop.
Save bentasm1/9573f5124f8c47931eda to your computer and use it in GitHub Desktop.
WC Vendors Remove Sold By for admin products on shop loop and single product page
remove_action( 'woocommerce_after_shop_loop_item', array('WCV_Vendor_Shop', 'template_loop_sold_by'), 9, 2);
remove_filter( 'woocommerce_get_item_data', array( 'WCV_Vendor_Cart', 'sold_by' ), 10, 2 );
remove_action( 'woocommerce_product_meta_start', array( 'WCV_Vendor_Cart', 'sold_by_meta' ), 10, 2 );
remove_filter( 'woocommerce_order_product_title', array( 'WCV_Emails', 'show_vendor_in_email' ), 10, 2 );
remove_filter( 'woocommerce_product_tabs', array( 'WCV_Vendor_Shop', 'seller_info_tab' ) );
remove_action( 'woocommerce_add_order_item_meta', array('WCV_Vendor_Shop', 'add_vendor_to_order_item_meta'), 10, 2 );
remove_action( 'woocommerce_after_shop_loop_item', 'loop_sold_by', 8 );
remove_action( 'woocommerce_product_meta_start','product_sold_by', 8 );
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 != '1' ) { // Change "1" to the admins user id #
$sold_by = WCV_Vendors::is_vendor( $vendor_id )
? sprintf( '<a href="%s">%s</a>', 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 != '1' ) { // Change "1" to the admins user id #
$sold_by = WCV_Vendors::is_vendor( $vendor_id )
? sprintf( '<a href="%s" target="_TOP">%s</a>', 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 != '1' ) { // Change "1" to the admins user id #
$sold_by = WCV_Vendors::is_vendor( $vendor_id )
? sprintf( '<a href="%s" class="wcvendors_cart_sold_by_meta">%s</a>', 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/>';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment