Created
September 11, 2019 14:59
-
-
Save stevenroh/b2889251aac83dee0d48e793c5ebce56 to your computer and use it in GitHub Desktop.
Disable add to cart for product where price is 0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Disable add to cart for product where price is 0 */ | |
function rohs_is_purchasable( $purchasable, $product ){ | |
if( $product->get_price() == 0 ) | |
$purchasable = false; | |
return $purchasable; | |
} | |
add_filter( 'woocommerce_is_purchasable', 'rohs_is_purchasable', 10, 2 ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment