Categories

Featured templates

WooCommerce. How to hide prices and Add to Cart for unregistered users

Stacy Martin August 6, 2015
Rating: 4.3/5. From 4 votes.
Please wait...

WooCommerce. How to hide prices and Add to Cart for unregistered users

This tutorial shows how to hide Prices and Add to Cart for unregistered users in WooCommerce.

WooCommerce. How to hide prices and Add to Cart for unregistered users-1

  1. In order hide Prices and Add to Cart for unregistered users, log into WordPress Dashboard and navigate to the Appearance -> Editor tab. Open the custom-functions.php file.

  2. Please note if you’re editing file via FTP or cPanel file manager, you can find the file required in the wp-content/themes/themeXXXXX/includes folder on server.

  3. Please make sure to back up the file, i.e. save copy of the original file before editing it.

  4. Scroll down the file and paste the following code before the closing ?> tag:

    // Hide prices
        add_action('after_setup_theme','activate_filter') ;	
        function activate_filter(){
        add_filter('woocommerce_get_price_html', 'show_price_logged');
        }
        function show_price_logged($price){
        if(is_user_logged_in() ){
        return $price;
        }
        else
        {
        remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart' );
        remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
        remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
        remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
        return '<a href="' . get_permalink(woocommerce_get_page_id('myaccount')) . '">Login to See Prices</a>';
        }
        }
  5. Update the file and log out from admin panel to check the changes on the front-end:

    WooCommerce. How to hide prices and Add to Cart for unregistered users-2

Feel free to check the detailed video tutorial below:

WooCommerce. How to hide prices and Add to Cart for unregistered users

Top Premium Wordpress Themes
This entry was posted in WooCommerce Tutorials and tagged hide, price, unregistered, WooCommerce. Bookmark the permalink.

Submit a ticket

If you are still unable to find a sufficient tutorial regarding your issue please use the following link to submit a request to our technical support team. We'll provide you with our help and assistance within next 24 hours: Submit a ticket