I use Dokan and WooCommerce. I want to hide the add to cart buttons on the products, so sellers do not have payment set up in their seller dashboard.
I have the following function, but it does not work:
add_filter( 'woocommerce_is_purchasable','woocommerce_available_payment_gateways' function( $show_cart, $product, $available_payment_gateways ) {
$seller_id = get_post_field('post_author', $product->get_id());
if(isset($available_payment_gateways( $seller_id )) {
$show_cart = true;
} else {
$show_cart = false;
}
return $show_cart;
}, 10, 2 );
2
Answers
Good morning,
we found that dokan simply displays a message at the end when the customer enters his card to indicate that payment for the product is not possible because the seller has not entered a payment method. We would rather hide the add to cart button from visitors on products from sellers who have not entered a payment method in their seller dashboard.
There are a lot of mistakes in your code, and your question is not very clear. So I guess that you want to avoid a seller to be able of purchasing its own products.
Then try the following:
Code goes in function.php file of your active child theme (or active theme). It should work.