# Hide prices for logged-out visitors in WooCommerce

> Show a "Log in to see prices" message instead of the price and add-to-cart button for guests.

- Source: https://plugstack.dev/snippets/woocommerce-hide-prices-for-guests/
- Published by: PlugStack
- Last updated: 2026-09-24

```php
add_filter( 'woocommerce_get_price_html', function ( $price ) {
	return is_user_logged_in() ? $price : '<a href="' . esc_url( wc_get_page_permalink( 'myaccount' ) ) . '">Log in to see prices</a>';
} );
add_filter( 'woocommerce_is_purchasable', function ( $purchasable ) {
	return is_user_logged_in() ? $purchasable : false;
} );
```
