Skip to content

Instantly share code, notes, and snippets.

@dublado
Forked from claudiosanches/functions.php
Created June 8, 2018 03:26
Show Gist options
  • Save dublado/1ef6ff24cdeb740961da79e5f9c0e11b to your computer and use it in GitHub Desktop.
Save dublado/1ef6ff24cdeb740961da79e5f9c0e11b to your computer and use it in GitHub Desktop.
WooCommerce - Display price only for logged in users
<?php
function cs_prices_only_for_logged_in_users() {
if ( ! is_user_logged_in() && ! is_admin() ) {
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( 'init', 'cs_prices_only_for_logged_in_users' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment