Hello guys how are you? Welcome back to my channel. Today in this post I am going to show you Avoid vendors to purchase their own product in WooCommerce.
Guys I have used both latest versions WordPress 6.3 and WooCommerce 8.1.
Guys if you are new in WordPress or in WooCommerce then please check the below links for some good tutorials:
Guys here is the working code snippet and please use it carefully:
1. Guys here is the code snippet and you need to add your theme’s functions.php file:
guys also I will make it with ajax and share that as well
add_filter('woocommerce_is_purchasable', 'filter_woocommerce_is_purchasable', 10, 2 ); function filter_woocommerce_is_purchasable( $purchasable, $product ) { $seller_id = get_post_field('post_author', $product->get_id()); if( get_current_user_id() == $seller_id ) { $purchasable = false; } return $purchasable; }
This is it guys and if you will have any kind of query, suggestion or requirement then feel free to comment below.
Jassa
Developer’s King
Thanks
Tags:Woocommerce
Recent Comments