Hide prices and buttons for unregistered users

I'm setting up a site for a wholesaler.
He wants his product listing to be visible to all visitors but only wants prices and buying functionality (Add to Cart button) to be visible to users who are registered and logged in.

Is this possible?

  • globalupturn
    • WPMU DEV Initiate

    Thanks Phil.

    Yes I am willing to have a go at a bit of custom coding. What could possibly go wrong :slight_smile:

    I would also like some pointers on how to get the quantity option in the product listing too if that is possible. The reason for this is so his regular customers can just go down the list and type the quantity they want of each product and click add to cart with no page reloading until they change category or whatever.
    I can raise that as another topic if necessary.

    Thanks
    Shayne

  • Philip John
    • DEV MAN’s Apprentice

    Okay, cool...

    MarketPress basically provides filters in a lot of places, including when displaying the price and buy button.

    So, you need to add an action for the 'mp_product_price_tag' filter to hide the price and use the 'mp_buy_button_tag' filter to hide the buy now button.

    For info on how to use filters if you don't already know, see this Codex article: http://codex.wordpress.org/Function_Reference/add_filter

    As for adding the quantity that would be extra custom development further beyond the scope that we can really assist with here I'm afraid.

    Thanks,
    Phil

  • globalupturn
    • WPMU DEV Initiate

    Thanks Phil I'll have a look at that link.

    Unfortunately the lack of a quantity selector in the product list will probably be a deal breaker. I may have to look around to see if any alternative e-commerce addons have this feature for this project perhaps.

    I'm a bit surprised that this is an option on e-commerce packages because I have been asked about it by other prospective clients. Perhaps it is just a niche thing mainly requested by wholesalers.

    Thanks for your help and prompt responses Phil.

    Shayne

  • globalupturn
    • WPMU DEV Initiate

    Having left this for a while I came back to it tonight

    In case anyone else is interested here's the code I added to my theme's functions.php file to hide the prices and buy/add to cart buttons for non logged in users, sitewide:

    //hide prices & buy buttons from non logged in visitors
    if ( !is_user_logged_in() ) {
    	add_filter('mp_product_price_tag', '__return_false');
    	add_filter('mp_buy_button_tag', '__return_false');
    }

    As always any suggestions for improvement or advice on possible "gotchas" gratefully accepted.

    Shayne

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.