Only Members can see the Price(Price hidden for logged out customers as well)

This topic has 8 replies, 3 voices, and was last updated 8 years, 8 months ago ago by Jack Richardson

  • Avatar: LadyCouture
    Kimberly Ann
    Participant
    February 26, 2016 at 21:12

    Hi All,

    Please help me out to hide the price for non-members of our website. On the Theme Options, I tried disabling the “show Price” in both Single Product and Product Page layout but it’s not working. I added some codes to the Shop Page that they have to login to see shop, but if they search through google it displays the price of the product which I’m trying to do. Can anyone help me with this? I saw a thread of post about hiding a price to logged out customers but I can seem to find How it was solved. Please let me know as soon as possible.

    Thank you so much!

    7 Answers
    Avatar: Jack Richardson
    Jack Richardson
    Support staff
    February 27, 2016 at 10:54

    Hello,

    Please try the solution described here:
    http://businessbloomer.com/woocommerce-hide-price-add-cart-logged-users/

    Best regards,
    Jack Richardson.

    Avatar: LadyCouture
    Kimberly Ann
    Participant
    February 29, 2016 at 16:12

    Hi Jack,

    I cant see anything after the line”Hello,Please try the solution described here:

    Avatar: Jack Richardson
    Jack Richardson
    Support staff
    February 29, 2016 at 17:08

    Hello,

    Sorry, here is the link http://businessbloomer.com/woocommerce-hide-price-add-cart-logged-users/

    Best regards,
    Jack Richardson.

    Avatar: mcarbone
    mcarbone
    Participant
    March 4, 2016 at 06:04

    HI, I am trying to achieve the same result. I would like to hide prices and add to cart button unless a user is logged in. I am using a Legenda child theme and have everything working perfectly except the add to cart button is still on the single product page. The add to cart is not on the catalog / category pages.

    I used the code provided here: http://businessbloomer.com/woocommerce-hide-price-add-cart-logged-users/ in my functions.php file (code below).

    /**
     * @snippet       Hide Price & Add to Cart for Logged Out Users
     * @how-to        Watch tutorial @ http://businessbloomer.com/?p=19055
     * @sourcecode    http://businessbloomer.com/?p=299
     * @author        Rodolfo Melogli
     * @testedwith    WooCommerce 2.4.12
     */
     
    add_filter('woocommerce_get_price_html', 'bbloomer_show_price_logged');
     
    function bbloomer_show_price_logged($price){
    if(is_user_logged_in() ){
    return $price;
    }
    else
    {
    add_action( 'woocommerce_single_product_summary', 'bbloomer_print_login_to_see', 31 );
    add_action( 'woocommerce_after_shop_loop_item', 'bbloomer_print_login_to_see', 11 );
    remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
    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 );
    }
    }
     
    function bbloomer_print_login_to_see() {
    echo '<a href="' . get_permalink(woocommerce_get_page_id('myaccount')) . '">' . __('Login to see prices', 'theme_name') . '</a>';
    }

    I believe my issue is with the template because I tried this code with another template and it worked fine.

    I tried using a different hook in this line:
    remove_action( 'woocommerce_single_product_summary', woocommerce_template_single_add_to_cart', 30 );

    ….but that did not work.

    I also disabled all other plugins besides woocommerce and that did not work either. Website info in private content area.

    Any help and guidance is greatly appreciated.

    Please, contact administrator
    for this information.
    Avatar: Jack Richardson
    Jack Richardson
    Support staff
    March 4, 2016 at 17:57

    Hello @mcarbone,

    I’ve changed the mentioned code in child functions.php file to the following:

    add_filter('woocommerce_get_price_html', 'bbloomer_show_price_logged');
     
    function bbloomer_show_price_logged($price){
    if(is_user_logged_in() ){
    return $price;
    }
    else
    {
    add_action( 'woocommerce_single_product_summary', 'bbloomer_print_login_to_see', 31 );
    add_action( 'woocommerce_after_shop_loop_item', 'bbloomer_print_login_to_see', 11 );
    remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
    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 );
    remove_action( 'woocommerce_simple_add_to_cart', 'woocommerce_simple_add_to_cart', 30 );
    remove_action( 'woocommerce_variable_add_to_cart', 'woocommerce_variable_add_to_cart', 30 );
    }
    }
     
    function bbloomer_print_login_to_see() {
    echo '<a href="' . get_permalink(woocommerce_get_page_id('myaccount')) . '">' . __('Login to see prices', 'theme_name') . '</a>';
    }

    Please check the site now.

    Best regards,
    Jack Richardson.

    Avatar: mcarbone
    mcarbone
    Participant
    March 4, 2016 at 18:36

    YES!!!!!!!! Works perfectly! Thank you so much for the help. It is greatly appreciated.

    Avatar: Jack Richardson
    Jack Richardson
    Support staff
    March 4, 2016 at 18:42

    Hello @mcarbone,

    You are welcome!
    We’d be thankful if you leave a review on Theme Forest site http://themeforest.net/item/legenda-responsive-multipurpose-wordpress-theme/5888906/comments

    Best regards,
    Jack Richardson.

  • Viewing 8 results - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.Log in/Sign up

8theme customization service
We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.