i want show price registered users only. wrote separate plugin code removed on update.
below code, it's working problem not show text hyperlink.
i see "registered users able view pricing". no href account page.
add_filter('woocommerce_get_price_html','members_only_price'); function members_only_price($price) { if(is_user_logged_in()){ return $price; } else { 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 ); return 'only <a href="' .get_permalink(woocommerce_get_page_id('myaccount')). '">registered users</a> able view pricing.'; } }
im not sure if it'll work or not. looking @ code noticed didn't put space between "." on return.
try this
function members_only_price($price){ if(is_user_logged_in()) { return $price; } else { 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 ); return 'only <a href="' . get_permalink(woocommerce_get_page_id('myaccount')) . '">registered users</a> able view pricing.'; } }
note: not tested.