Home Forums WC Vendors Pro Support Few bugs Reply To: Few bugs

#59951
Anna
Member

@nofiski

yes i need revert for this too. revert goddamit!! ?

Reversion complete. 😉


@jaypreet

Essentially you will need to hide the add to cart button if the product vendor (post_author) is the one viewing the page.
Something like this:

/* remove add-to-cart from shop page for product author  */
add_action('woocommerce_after_shop_loop_item_title','hide_add_to_cart_vendor_shop') ;
function hide_add_to_cart_vendor_shop(){
    $user_id = get_current_user_id();
    $author_id = get_post_field('post_author', get_the_ID());
    if($user_id == $author_id){
        remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
    }
}

/* remove add-to-cart from single product page for product author  */
add_action('woocommerce_before_single_product_summary','hide_add_to_cart_vendor_product_page') ;
function hide_add_to_cart_vendor_product_page(){
    $user_id = get_current_user_id();
    $author_id = get_post_field('post_author', get_the_ID());
    if($user_id == $author_id){
        remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
    }
}