• Resolved prokops

    (@prokops)


    I can enable the option: “Hide Price and Add to Cart button”.

    What I want to do is “Show Price and hide Add to Cart button”

    Is there a snippet or option for that? I could hide button with css, but this solution is clumsy.

Viewing 1 replies (of 1 total)
  • Plugin Support Jeff Alvarez

    (@superlemon1998)

    Hi @prokops,

    Yes, you can do that with a snippet. Please add the following to your child theme’s functions.php or through the WPCode plugin

    
    add_action('wp_head','remove_add_to_cart');
    
    function remove_add_to_cart(){
    	if(!is_user_logged_in()){
    		add_filter( 'woocommerce_is_purchasable', '__return_false');
    	}
    }
    
    add_filter('woocommerce_short_description','ask_login');
    
    function ask_login($description){
    	if(!is_user_logged_in()){
    	echo "<p><a >Login to add to cart</a> </p>";
    	}
    	return $description;
    }

    This will allow the users to see the price but be unable to purchase until they log in, it’ll also show a login to view the price on the short description area on the product page.

    Please note to update the https://google.com link to the link of your website’s login page.

    I’ll include some useful articles if you’d like to further learn the code:

    Hope this helps. Let us know if you have other questions.

    Cheers,

Viewing 1 replies (of 1 total)
  • The topic ‘Show price, hide button’ is closed to new replies.