I have an event based WordPress website on that I sell tickets using WooCommerce. Is there any way to hide the "add to cart" button for the product having cost zero?
Thanks.
I have an event based WordPress website on that I sell tickets using WooCommerce. Is there any way to hide the "add to cart" button for the product having cost zero?
Thanks.
This may be a suitable solution according to the documentation
woocommerce_is_purchasable – filter
Function name: WC_Product::is_purchasable
is_purchasable() — Returns false if the product cannot be bought.
https://woocommerce.wp-a2z.org/oik_api/wc_productis_purchasable/
function remove_add_to_cart_on_0 ( $is_purchasable, $product ){
if( $product->get_price() == 0 ) {
return false; }
else {
return $is_purchasable; }
}
add_filter( 'woocommerce_is_purchasable', 'remove_add_to_cart_on_0', 10, 2 );