- What is Astra Pro Add on?
- What Is a Child Theme and How To Install It for Astra?
- How to Activate Astra Pro Addon License?
- How to Get License Key of Astra Pro?
- How to Install Astra Pro Plugin?
- Getting Started with Astra Pro Addon Plugin
- Getting error – The package could not be installed. The theme is missing the style.css stylesheet?
- Do Not See License Activation Form for Astra Pro Addon Plugin?
- How to Install Astra Theme?
- Astra – Customize the Submenu
- The Blank Screen in the Customizer Area
- How to use the color palette of the Astra theme
- How to Import / Export Astra Customizer Settings
- How To Disable Logo Cropping
- How to Create a Sticky Sidebar for Your WooCommerce Shop Page
- How to use dynamic customizer from Astra 4.0.0
- How to Change the Typography of the Astra Menu
- Simplify Your Site Design with the New Style Guide
- How to Translate Astra Theme / Plugins in Your Own Language using GlotPress?
- How to Turn Astra Multilingual with WPML?
- How To Translate Site Builder With WPML?
- How to Translate Astra Strings with WPML?
- How Translations can be Manually Exported and Uploaded to the Site?
- How to Turn Astra Website Multilingual with Polylang?
- How to Translate Categories, Tags, and Astra Strings with Polylang
- How to Turn Astra Website Multilingual with TranslatePress?
- How to translate the WooCommerce string?
- Footer Custom Text Helper Strings
- Does Astra support Beaver Themer Plugin?
- Increasing the PHP Memory Limit of Your Website
- How to Disable Header or Footer for a Landing Page or Post?
- Where Does Astra Primary Color Setting Take Effect?
- How to Adjust the Width of Your Sidebar?
- How to Update the Plugin Manually from WordPress Backend?
- Recommended Settings for Elementor and the Astra Theme
- Recommended Settings for Beaver Builder and the Astra Theme
- How Do License Upgrades Work?
- How to Renew Yearly License?
- How to Apply For Brainstorm Force Affiliate Program? (Become Astra Affiliate)
- How to Manage License on Store?
- How To Update Your Payment Method?
- How do I check my Support Ticket History?
- Frequently Asked Questions – VIP Priority Support
- How to Process Refund Requests?
- Fix Swap Sections Not Working on Mobile (Old Astra Header)
- How to Remove Google Fonts Suggestions in Astra Theme?
- Remove default stretched block layout spacing
- How to Change the Logo on Specific Pages?
- How to remove horizontal & vertical gallery layouts from a single product page?
- Introducing New Filter to Enable/Disable Rank-Math Theme Support
- Enable/Disable YouTube videos from Astra admin dashboard
- How to Fix the Line Height Unit being converted to “EM”?
- How to Change WordPress Post labels to Projects
- Fix for – The PCLZIP_ERR_BAD_FORMAT (-10) Error
- Fix for – Parse error: syntax error, unexpected T_FUNCTION
- How to fix Fatal Error / White Screen of Death?
- Fix for- cURL error 51: SSL: no alternative certificate subject name matches target host name ‘websitedemos.net’
- Getting error – The package could not be installed. The theme is missing the style.css stylesheet?
- ‘The preview could not be loaded’ Pop Up with Astra and Elementor
- Troubleshooting Steps ( with Health Check & Troubleshooting plugin )
- How to Deal with Update Issues in Astra Theme and Astra Pro Addon?
- Blog Featured Image Size Not Working / Error in Image Processing Library
How to Hide Price & Add to Cart for Logged Out Users in Astra Theme
This guide provides step-by-step instructions on how to hide “Product Prices” and the “Add to Cart” button for users who are not logged in on a WordPress site using the Astra theme.

You can accomplish this by adding a custom code snippet to the child theme’s functions.php file or using Astra Pro Custom Layouts Hooks.
How to Hide Price & Add to Cart for Logged Out Users in Astra Theme
Before proceeding, ensure that the following requirements are met:
- WordPress is installed and activated.
- Astra theme is installed and activated.
- A child theme is set up (recommended for making code customizations).
Here is the code snippet that will be used to hide prices and the Add to Cart button for logged-out users:
add_filter( 'woocommerce_get_price_html', 'astra_hide_price_addcart_not_logged_in', 9999, 2 );
function astra_hide_price_addcart_not_logged_in( $price, $product ) {
if ( ! is_user_logged_in() ) {
$price = '<div><a href="' . get_permalink( wc_get_page_id( 'myaccount' ) ) . '">' . __( 'Login to see prices', 'astra' ) . '</a></div>';
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
add_filter( 'woocommerce_is_purchasable', '__return_false' );
}
return $price;
}
Implementation Methods
Follow the below enlisted steps to implement the code snippet:
Method 1: Using Child Theme Functions.php
- Open your WordPress site’s file system.
- Navigate to wp-content/themes/your-child-theme/ directory.
- Locate and edit the functions.php file using a text editor.
- Copy and paste the provided code snippet at the end of the file.
- Save the file by clicking “Update File” button.

Method 2: Using Astra Pro Custom Layouts Hooks
- Go to your WordPress admin dashboard.
- Navigate to Astra > Site Builder.
- Select the appropriate location where you want to apply the customization (e.g., Single Product, Shop Page).
- Click on Add New Layout or edit an existing one.
- Switch to the Hooks tab.
- Paste the code snippet into the Before Content or After Content field.
- Save the changes.
Note:
To ensure that the customization is functioning as intended, log out of your WordPress site and navigate to a product page or the shop page. Verify that prices are concealed, and the Add to Cart button is not visible. Click on the provided link, which should redirect you to the login page.
If a user is not logged in, a new message will appear, prompting them to log in to view prices. This process helps confirm that the implemented changes are working as expected.

We hope this document has been helpful. If you have any queries, feel free to leave a comment below.
We don't respond to the article feedback, we use it to improve our support content.