Hide Product Pricing for Logged-Out Users in WooCommerce
Running a WooCommerce store often means tailoring the shopping experience to different types of users.
One common customization is hiding product prices from visitors who aren’t logged in.
Whether you’re running a wholesale store, a members-only shop, or simply want to encourage account creation, this tweak can be incredibly useful.
In this post, we’ll show you how to hide product pricing for logged-out users using a simple code snippet—no plugins required.
Why Hide Pricing from Logged-Out Users?
Hiding product pricing for logged-out users is a simple yet powerful way to control access and encourage user engagement.
With just a few lines of code, you can transform your WooCommerce store into a more personalized and secure shopping experience.
Here are a few reasons you might want to restrict price visibility:
- Wholesale or B2B stores: Only registered customers should see pricing.
- Membership-based shops: Encourage users to sign up or log in.
- Custom pricing models: Prices vary by user role or account status.
- Lead generation: Drive account creation by gating pricing info.
Code Snippet
Add the following code to your theme’s functions.php file or a custom plugin
How It Works
- is_user_logged_in() checks if the visitor is logged in.
- If not, it hooks into woocommerce_get_price_html, which controls how prices are displayed.
- Instead of showing the price, it returns a login link to the WooCommerce “My Account” page.
Customization Tips
Want to tailor the message or behavior? Here are a few ideas:
- Change the link text:
__(‘Please log in to view pricing’, ‘your-theme-textdomain’)
- Add styling or icons:
return ‘<a class=”login-to-view-price” href=”‘ . get_permalink(wc_get_page_id(‘myaccount’)) . ‘”><i class=”fas fa-lock”></i> Login to see prices</a>’;
- Redirect to a custom login page:
- Replace
wc_get_page_id('myaccount')with your custom login page URL.
- Replace
Important Notes
- This snippet only affects the price display. Products are still visible and purchasable unless further restrictions are added.
- To fully restrict purchasing, consider hiding the “Add to Cart” button for logged-out users as well.
- Always test changes on a staging site before deploying to production.
Bonus: Hide Prices on Product Archives Too
To ensure prices are hidden on category and shop pages, the same filter works globally. But if you want more control, you can also use conditional logic in your templates:
if ( is_user_logged_in() )
{
echo $product->get_price_html();
} else {
echo ‘<a href=”‘ . get_permalink(wc_get_page_id(‘myaccount’)) . ‘”>Login to see prices</a>’;
}
Conclusion
I welcome your thoughts, questions or suggestions on my article on how to hide product pricing for logged-out users with a WooCommerce store.
You may support my work by sending me a tip using your Brave browser or by sending me a one time donation using your credit card.
Let me know if you found any errors within my article or if I may further assist you by answering any additional questions you may have.




