Hi all, I’m facing a huge problem on Legenda theme. I have to remove the “Add to Cart” button from the single page for non logged in users. Usually I add the following code to functions.php (in this case we have to consider init.php inside Framework folder:
function members_only_price($price){
if(is_user_logged_in() ){
return $price;
}
else {
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 10 );
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
}
}
add_action('init','members_only_price');
Unfortunately this doesn’t work for single product page, because the content-single-product.php have a single php instruction for “Add to Cart”:
`<?php woocommerce_template_single_add_to_cart(); ?>
How should I solve this issue? Thanks in advance for your replies.
Best Regards.