I’m using Woodmart theme that allow me to hide prices for not logged in users. By the way, prices per unit are displayed in the shop, also for guests. Is there a simple way to hide them?
Open
Last updated: February 24, 2025
Log in to comment on this feature request.
Yes perfect, it works fine. Thank you!
Hi,
it can be done through a piece of code inserted in functions.php of your theme or in PHP snippet.
There are two filters which can be hooked, and it’s possible to stop the price generation there:
apply_filters( ‘mcmp_ppu_process_product’, true, $html_price, $product );
apply_filters( ‘mcmp_ppu_process_variation’, true, $args, $product, $variation );
So in your case the code should look like this:
function mcmp_hide_guest_prices( $process_product ) {
// Returns false if user is not logged in.
return is_user_logged_in();
}
add_filter( ‘mcmp_ppu_process_product’, ‘mcmp_hide_guest_prices’ );
add_filter( ‘mcmp_ppu_process_variation’, ‘mcmp_hide_guest_prices’ );
This should work. Let me know if you encounter any problem.