- This topic has 3 replies, 3 voices, and was last updated 7 years, 4 months ago by .
Viewing 4 posts - 1 through 4 (of 4 total)
Viewing 4 posts - 1 through 4 (of 4 total)
- You must be logged in to reply to this topic.
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
Hi there,
I’m afraid I’m not familiar enough with WC to know exactly the right code.
Have you tried asking in their forums?
I did, but they all give me code that I should paste at the end of the functions.php file, which I did and it works, but not for the cart.
Hope you can help me out, because I cannot, even may not start (restricted by Herbalife) my website, if I show prices before customers login.
Have you asked them for code for the cart as well? Like I said I’m no expert when it comes to WC, so I wouldn’t know what to do without researching it first.
GeneratePress
© 2023 EDGE22 Studios LTD.