How to remove add to cart buttons for users not logged in

We're shifting our Forum based support to a more dedicated support system!

We'll be closing our Forum support from 10th June, 2020 and move to Email Support assistance.

  • If you are a WCFM premium add-ons user, contact us- here
  • Want to know more before buying our add-ons? Send Pre sale queries- here
  • If you are a WCFM free user, please open a support ticket at
  • For WCFM App related queries, reach us- here
From now the forum will be read-only!

Viewing 0 reply threads
  • Author
    • #100707

      Hello i’m trying to remove the add to cart button for users that are not logged in in the website. Ussualy i use something like this

      add_action( 'init', 'hide_price_add_cart_not_logged_in' );
       function hide_price_add_cart_not_logged_in() {   
        if ( ! is_user_logged_in() ) {      
         remove_action( 'woocommerce_external_add_to_cart', 'woocommerce_template_loop_add_to_cart', 10 );
         remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
         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( 'woocommerce_single_product_summary', 'print_login_to_see', 31 );
         add_action( 'woocommerce_after_shop_loop_item', 'print_login_to_see', 11 );
       function print_login_to_see() {
       echo '<a class="re_track_btn woo_loop_btn btn_offer_block" href="' . get_permalink(wc_get_page_id('myaccount')) . '">' . __('See price', 'rehub') . '</a>';

      But i notice that you already remove the woocommerce_single_product_summary actions

      i’m using the comparison price view for the product page from the rehub theme (Revendor Child theme).

Viewing 0 reply threads
  • You must be logged in to reply to this topic.