Avada Forums Community Forum Remove 'Add to Cart' for non logged in users Wocommerce

Viewing 1 post (of 1 total)
  • Author
    Posts
  • BayKingChrysler
    Participant
    Post count: 1

    Does anyone know how to do this? I found some code that does a good job of removing the price for non logged in users and replacing it with text but the add to cart button still shows up. Anyone know how to tweak this code to make the cart disappear?

    `
    add_filter(‘woocommerce_get_price_html’,’members_only_price’);

    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’ );
    remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_price’, 10 );
    remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_add_to_cart’, 30 );
    remove_action( ‘woocommerce_after_shop_loop_item_title’, ‘woocommerce_template_loop_price’, 10 );
    return ‘Only Registered Users are able to view pricing.’;
    }

    }

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.