Home Forums WoodMart support forum Catalog Mode

Catalog Mode

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #20582

    jinsley8
    Participant

    Hi,

    I’m using this plugin to hide the price and Add to Cart buttons from users who are not logged in.

    https://woocommerce.com/products/catalog-visibility-options/

    However, it doesn’t work on your quickview. When not logged in, you can press the product quickview to see price and button still.

    Is there a function I can use to only show these conditionally to users logged in only?

    #20585

    Artem Temos
    Keymaster

    Hello,

    It seems to be a problem in the plugin since it doesn’t work with AJAX loaded content. Our quick view uses the same WooCommerce functions as on the single product page. If you want to modify it check the file basel/woocommerce/content-quick-view.php.

    Regards

    #20601

    jinsley8
    Participant

    Okay I fixed it with my own functions – for anyone looking to do the same:

    add_action('after_setup_theme','custom_activate_filter') ; 
    
    function custom_activate_filter()
    {
       add_filter('woocommerce_get_price_html', 'custom_show_price_logged');
    }
    
    function custom_show_price_logged($price)
    {
       if(is_user_logged_in() )
       {
          return $price;
       }
       else
      {
        // Remove Price from Single Product Page
        remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
    
         // Remove Price from Shop/Category Pages
        remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
    
        // Remove Add to Cart from Shop/Category Pages (Limitation: This code will remove "Select Option" from Grouped and Variable product also
        remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
    
        // Remove Add to cart from Single Product Page
        remove_action( 'woocommerce_simple_add_to_cart', 'woocommerce_simple_add_to_cart', 30 );
        remove_action( 'woocommerce_grouped_add_to_cart', 'woocommerce_grouped_add_to_cart', 30 );
        remove_action( 'woocommerce_variable_add_to_cart', 'woocommerce_variable_add_to_cart', 30 );
        remove_action( 'woocommerce_external_add_to_cart', 'woocommerce_external_add_to_cart', 30 );
        remove_action( 'woocommerce_single_variation', 'woocommerce_single_variation_add_to_cart_button', 20 );
    
        return '<a href="/login">Login for pricing</a>';
      }
    }
    #20622

    Artem Temos
    Keymaster

    Hi,

    Thank you very much for posting your solution here.

    Regards

Viewing 4 posts - 1 through 4 (of 4 total)