Deny product purchase in lifetime on cart and checkout in WooCommerce on child sites.
Snippet Type
Execute on Child Sites
Snippet
add_filter( 'woocommerce_is_purchasable', 'bbloomer_deny_purchase_if_already_purchased', 9999, 2 );
function bbloomer_deny_purchase_if_already_purchased( $is_purchasable, $product ) {
if ( is_user_logged_in() && wc_customer_bought_product( '', get_current_user_id(), $product->get_id() ) ) {
$is_purchasable = false;
}
return $is_purchasable;
}