Hi,
I am using GeneratePress premium version.
I would like to hide the prices for visitors that are not logged in, or don’t have an account.
In replacement, I would like to show some text like: Login to see price, with a link to the login page.
Without login, prices should not be seen anywhere, also not in the cart.
Could you help me out please. I have tried many suggestions from other forums, editing functions.php of the generatepress theme. I got to hide the price from the products pages, but NOT from the cart. I used this code:
add_action('after_setup_theme','activate_filter') ;
function activate_filter(){
add_filter('woocommerce_get_price_html', 'bbloomer_show_price_logged');
}
function bbloomer_show_price_logged($price){
if(is_user_logged_in() ){
return $price;
}
else
{
return 'Login to See Prices';
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 );
}
}
Thanks, Michiel