Home Forums Basel support forum Pricing Shows When Logged Out Users Adds Item to Cart

Pricing Shows When Logged Out Users Adds Item to Cart

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #7505

    robertarrow
    Participant

    I know we’ve worked on this before, but the client has just notified me that a logged-out user, can still add a product to the cart and see the pricing for that product in the cart. Is there anything we can do to fix that?

    // Hide prices
        add_action('after_setup_theme','activate_filter') ; 
        function activate_filter(){
        add_filter('woocommerce_get_price_html', 'show_price_logged');
        }
        function show_price_logged($price){
        if(is_user_logged_in() ){
        return $price;
        }
        else
        {
        remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
        remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
        return '<a href="' . get_permalink(woocommerce_get_page_id('myaccount')) . '">Login to See Prices</a>';
        }
        }
    
    add_filter('body_class','nec_logged_in_filter');
     
    function nec_logged_in_filter($classes)
    {
    	if( is_user_logged_in() )
    	{
    		$classes[] = 'logged-in';
    	} else {
    		$classes[] = 'logged-out';
            }
     
    	// return the $classes array
    	return $classes;
    }
    
    #7506

    robertarrow
    Participant

    Is there any way to use one of these alternatives? I’m sorry I have no PHP experience and our Web Developer is no longer with us.

    https://businessbloomer.com/woocommerce-hide-price-add-cart-logged-users/

    #7509

    Artem Temos
    Keymaster

    Hello,

    But how your users are able to add products to cart if there are no add to cart button visible on your shop pages?

    Regards

    #7510

    robertarrow
    Participant

    Only users that have been approved, should be able to purchase anything on this particular site. If you do not have an account, you should only be able to see the site as a catalog, with all of the variations of the products and what not, but not as a “shop” if that makes sense.

    #7511

    Artem Temos
    Keymaster

    Yes, we understand. But we just visited your website and see that it works in exactly this way. There are no add to cart buttons on your website when I’m not logged in.

    Regards

    #7515

    robertarrow
    Participant

    https://www.aquahairextensions.com/product-category/clip-in-hair-extensions/

    https://postimg.org/gallery/26fmk537w/

    Where it says ‘Login to See Prices’ if you hover over it, it changes to ‘Add to Cart,’ which it then does and then you can see ‘View Cart’

    #7518

    Artem Temos
    Keymaster

    Ok, try to hide it with Custom CSS also

    .logged-out .btn-add {
    	display:none;
    }

    Regards

Tagged: 

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