been using this code to hide prices..
add_filter('woocommerce_get_price_html','members_only_price');
function members_only_price($price){
if(is_user_logged_in() ){
return $price;
}
else return '<a href="' .get_permalink(woocommerce_get_page_id('myaccount')). '">Login</a> or <a href="'.site_url('/wp-login.php?action=register&redirect_to=' . get_permalink()).'">Register</a> to see price!';
}
tried modifying it to use for hiding add to cart as well..but no avail..
anyone?
Extending the above code (thanks Ewout), the following code will get rid of all prices and ‘add to cart’ buttons on all woocommerce products, as well as provide an explanation as to why. I needed the code for a website that offers direct selling products and to comply with their rules, I cannot show prices to the general public.
Add the filter to your theme’s functions.php file.
Have you tried something like this? You would set woocommerce to only show prices when user is logged in.
Reference: http://docs.woothemes.com/document/catalog-visibility-options/
EDIT:
The reference material has the cart visibility reference
What about CSS?
We can do this easily through the
woocommerce_is_purchasable
andwoocommerce_get_price_html
hooks.Code:
And the result:
Source: WooCommerce – Disable purchase for non-logged-in users. (Remove add-to-cart button).