Hide woocomerce product price, quantity, add to cart button for guest (not logged in) users | Wordpress Hacks
This is very simple gist to disable or hide product prices for guest users. Only logged in user can see product prices, quantity and add to cart button.
Only registered & logged in user can add to cart and make order
I've encountered a situation where I need to display the product to any users including guest users. But only registered user can order, meaning it needs to hide product prices, quantity field, add to cart button. If you are in same situation, just copy paste this snippet in your functions.php or your plugin code.
Note: Without having the price it also disables the quantity field and add to cart button.
Filter woocommerce product price using wordpress hooks
If you need to do other operations like customize product prices such as apply discounts, other form of custom calculations these are the hooks you need to consider
woocommerce_product_get_sale_price woocommerce_product_variation_get_sale_price woocommerce_product_get_price woocommerce_product_variation_get_price woocommerce_variation_prices_price woocommerce_variation_prices_sale_price
Comments
Leave a comment
You are not LoggedIn but you can comment as an anonymous user which requires manual approval. For better experience please Login.