<?php
// WP Snippet Press – WooCommerce snippet
// Hide product prices for non-logged-in users
add_filter( 'woocommerce_get_price_html', 'wpsnippetpress_hide_price_for_guests' );
function wpsnippetpress_hide_price_for_guests( $price ) {
if ( ! is_user_logged_in() ) { // Check if user is logged in
return '<span class="wpsp-login-msg">Login to see price</span>'; // Replace price with message
}
return $price; // Show normal price for logged-in users
}PHP