Skip to content

Instantly share code, notes, and snippets.

@claudiosanches
Last active June 8, 2018 03:26
Show Gist options
  • Save claudiosanches/5996920 to your computer and use it in GitHub Desktop.
Save claudiosanches/5996920 to your computer and use it in GitHub Desktop.
WooCommerce - Show add to cart button only for logged users
<?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_add_to_cart() {
if ( is_user_logged_in() ) {
global $product;
do_action( 'woocommerce_' . $product->product_type . '_add_to_cart' );
}
}
@wilburlikesmith
Copy link

Like a charm :) Now to add a register / login link...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment