Created
June 16, 2020 05:22
-
-
Save homfarnam/6542fed4aab9b4b3e3e28b75301cafea to your computer and use it in GitHub Desktop.
show products prices only for users
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function wootips_hide_price_add_cart_not_logged_in() { | |
if ( !is_user_logged_in() ) { | |
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 ); | |
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 ); | |
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 ); | |
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 ); | |
add_action( 'woocommerce_single_product_summary', 'wootips_print_login_to_see', 31 ); | |
add_action( 'woocommerce_after_shop_loop_item', 'wootips_print_login_to_see', 11 ); | |
} | |
} | |
function wootips_print_login_to_see() { | |
echo '<br /><br /><a href="' . get_permalink(wc_get_page_id('myaccount')) . '"></a><br /><br />'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment