Skip to content

Instantly share code, notes, and snippets.

@ddbs
Forked from claudiosanches/functions.php
Last active August 29, 2015 14:01
Show Gist options
  • Save ddbs/0819b092110d79bd77ec to your computer and use it in GitHub Desktop.
Save ddbs/0819b092110d79bd77ec to your computer and use it in GitHub Desktop.
WooCommerce: Hide price and add-to-cart button for non-logged in users.
//Hide price and add-to-cart button for non-logged in users.
function woocommerce_template_loop_price() {
if ( is_user_logged_in() )
woocommerce_get_template( 'loop/price.php' );
}
function woocommerce_template_loop_add_to_cart() {
if ( is_user_logged_in() )
woocommerce_get_template( 'loop/add-to-cart.php' );
}
function woocommerce_template_single_price() {
if ( is_user_logged_in() )
woocommerce_get_template( 'single-product/price.php' );
}
function woocommerce_template_single_add_to_cart() {
global $product;
if ( is_user_logged_in() )
do_action( 'woocommerce_' . $product->product_type . '_add_to_cart' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment