Skip to content

Instantly share code, notes, and snippets.

@stevenroh
Created September 11, 2019 14:59
Show Gist options
  • Save stevenroh/b2889251aac83dee0d48e793c5ebce56 to your computer and use it in GitHub Desktop.
Save stevenroh/b2889251aac83dee0d48e793c5ebce56 to your computer and use it in GitHub Desktop.
Disable add to cart for product where price is 0
<?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