Last active
June 8, 2018 03:26
-
-
Save claudiosanches/5996920 to your computer and use it in GitHub Desktop.
WooCommerce - Show add to cart button only for logged users
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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' ); | |
} | |
} |
I just try it and it works great for me. Thank You!
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
I tried this, but doesn't work.
Perhaps has to be connected to a wooCommerce hook/filter? And if yes, which of them?