How can I remove the ‘Add to Cart’ button based on user roles?
// REMOVE ADD TO CART BUTTON FOR ADMIN USERS
add_action('wp_loaded', 'wpsc_check_user_role');
function wpsc_check_user_role() {
$current_user = wp_get_current_user();
if (!empty($current_user->roles) && $current_user->roles[0] === 'administrator') {
add_filter('woocommerce_is_purchasable', '__return_false');
}
}