This topic has 8 replies, 3 voices, and was last updated 8 years, 9 months ago ago by Jack Richardson
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!
Hello,
Please try the solution described here:
http://businessbloomer.com/woocommerce-hide-price-add-cart-logged-users/
Best regards,
Jack Richardson.
Hi Jack,
I cant see anything after the line”Hello,Please try the solution described here:
Hello,
Sorry, here is the link http://businessbloomer.com/woocommerce-hide-price-add-cart-logged-users/
Best regards,
Jack Richardson.
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.
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.
YES!!!!!!!! Works perfectly! Thank you so much for the help. It is greatly appreciated.
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.
Tagged: hidden, logged out, members, persuasive, price, woocommerce, wordpress
You must be logged in to reply to this topic.Log in/Sign up