Hiding product price
-
Hi guys, sorry but I didn’t know where to post this.
I have added the following code to hide product prices for logged out users:
add_action( 'init', 'hide_price_add_cart_not_logged_in' ); function hide_price_add_cart_not_logged_in() { if ( ! is_user_logged_in() ) { add_action( 'woocommerce_single_product_summary', 'print_login_to_see', 31 ); add_action( 'woocommerce_after_shop_loop_item', 'print_login_to_see', 11 ); } } function print_login_to_see() { echo '<a href="' . get_permalink(wc_get_page_id('myaccount')) . '">' . __('Login to see price', 'theme_name') . '</a>'; }
And it worked just fine, however prices are still showing up in google image search results as you can see in the screenshot:
https://i.ibb.co/xXnRbDj/ss.png
What can I do about this? I really need for people to not be able to see prices without an account. Is anyone able to help?
Much appreciated
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Hiding product price’ is closed to new replies.