WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
[closed] Hide Prices (27 posts)

  1. MaddTechWF
    Member
    Posted 1 year ago #

    Is there a way to hide prices until a user logs?

    http://wordpress.org/extend/plugins/woocommerce/

  2. bheadrick
    Member
    Posted 1 year ago #

    This will replace any price text with "login or register to see price"
    (including links to the login and registration pages).
    user will be redirected to the page the page he was on when the register link was clicked after registration, but that doesn't seem to work for the login.

    add_filter('woocommerce_get_price_html','members_only_price');
    function members_only_price($price){
    if(is_user_logged_in() ){
        return $price;
    }
    else return '<a href="' .get_permalink(woocommerce_get_page_id('myaccount')). '">Login</a> or <a href="'.site_url('/wp-login.php?action=register&redirect_to=' . get_permalink()).'">Register</a> to see price!';
    }
  3. MaddTechWF
    Member
    Posted 1 year ago #

    Is there a way that I could still show like a "$-" in the price class and the hyperlinks that you provided in your example?

  4. bheadrick
    Member
    Posted 1 year ago #

    Sure, just replace

    else return '<a href="' .get_permalink(woocommerce_get_page_id('myaccount')). '">Login</a> or <a href="'.site_url('/wp-login.php?action=register&redirect_to=' . get_permalink()).'">Register</a> to see price!';

    with

    else return '<span class="amount">$-</span><a href="' .get_permalink(woocommerce_get_page_id('myaccount')). '">Login</a> or <a href="'.site_url('/wp-login.php?action=register&redirect_to=' . get_permalink()).'">Register</a> to see price!';

  5. webseosteve
    Member
    Posted 1 year ago #

    Thankyou so much for providing this mod. It is exactly what I was after. I do have one question. Were do I find then add this piece of code?

    Steve

  6. bheadrick
    Member
    Posted 1 year ago #

    it goes in your theme's functions.php

  7. rhonz10
    Member
    Posted 1 year ago #

    hi Bryan, can you help me with this one, I've posted this last week but nobody seems to have the answer.

    http://wordpress.org/support/topic/blank-select-option-on-checkout-shipping-method

    sorry if this is Off the topic.

    thanks.

    Rhon

  8. Sumim
    Member
    Posted 1 year ago #

    Hello, Bryan,
    I just used the filter you provided (showing the prices only to registered or logged in customers) - thank you much!!:)
    However, the 'Add to Cart" botton stays there as well. It looks a bit messy. Is there an action I can add so that the 'Add to Cart' botton would show up together with the prices (displayed to registered or logged in customers only)?

    Here is the link - http://www.sumim.lt/shop/product-category/brangakmeniai-4/naturalus-spalvotieji-brangakmeniai/page/2/

    Thank you :)

  9. Brad Smith
    Member
    Posted 1 year ago #

    I'd like to hide all pricing as I'm using this cart as a 'request for quote' tool.
    Would this addition to the functions file hide all pricing? Really unsure of what I wrote. Thanks.

    /**
     * Hides all pricing
     */
    function hide_all_wc_prices( $price, $product ) {
      return '';
    }
    
    add_filter( 'woocommerce_get_price_html'), 'hide_all_wc_prices',);
  10. viviansank
    Member
    Posted 1 year ago #

    show only prices for people in both logged as part of the products at checkout.
    if the visitor press ADD button, see ready the same price not being logged.
    Now logged oh yes he can see .. only logged can see.

    BradSmith send your suggestion, but if the user login in wordpress ?

    any ideas?

  11. aimeevee
    Member
    Posted 1 year ago #

    the solution suggested in the first reply worked wonderfully...however the variable price still displays is there a way to block that as well?

  12. Coen Jacobs
    Member
    Plugin Author

    Posted 1 year ago #

    For everyone who is looking for a plug & play plugin, we have the premium Catalog Visibility Options extension that does just this - optional for not logged in users. This does not enable you to make it a 'request a quote' feature, but you can make the 'add to cart' button change into an 'email us' link, for example.

  13. aimeevee
    Member
    Posted 1 year ago #

    I was not looking for a plug & play plugin but just because I did not want to pay. I found a quick fix using the

    <?php if (is_user_logged_in() ) { //only logged in user can view this ?>

    Here is the FULL code which also hides the add to cart button ;)

    <?php do_action('woocommerce_before_add_to_cart_button'); ?>
    <?php if (is_user_logged_in() ) {  //only logged in user can view this ?>
    	<div class="single_variation_wrap" style="display:none;">
    		<div class="single_variation"></div>
    		<div class="variations_button">
    			<input type="hidden" name="variation_id" value="" />
    			<?php woocommerce_quantity_input(); ?>
    			<button type="submit" class="single_add_to_cart_button button alt"><?php echo apply_filters('single_add_to_cart_text', __('Add to cart', 'woocommerce'), $product->product_type); ?></button>
    		</div>
    	</div>
    	<div><input type="hidden" name="product_id" value="<?php echo esc_attr( $post->ID ); ?>" /></div>
    
    	<?php do_action('woocommerce_after_add_to_cart_button'); ?>
    
    </form>
    <?php } ?>

    Place the code in the woocommerce/templates/single-product/add-to-cart/variable.php file on both in the woocommerce plugin as well as any variable.php which may be included in your theme's files

  14. Sumim
    Member
    Posted 1 year ago #

    I would like to ask about the Catalogue Visibility Options extension - does it provide an opportunity to authenticate (approve) newly registered members who want to see the prices?

    Thank you.

  15. Brad Smith
    Member
    Posted 1 year ago #

    Hey Sumim, I'm using the Catalog Visibility Options extension. I added the users I knew in advance could view pricing but then blocked new users from registering.

    You want to approve/deny registrations as they occur. Here are some plugins that may be a good fit: http://wordpress.org/extend/plugins/search.php?q=Register+Admin+Approval&sort=

  16. MaddTechWF
    Member
    Posted 1 year ago #

    @bheadrick - The code you provided me a few months ago worked like a charm but I just realized that the "Add to Cart" button still shows and the customer doesn't want it to show either. How can I make that button disappear until they are logged in.

    On a side not, does anyone happen to know how I can make a user "verify" their email address after the create a new account before they can login and purchase. Any ideas?

  17. Sumim
    Member
    Posted 1 year ago #

    To Aimeevee:
    Thank you for the code!
    However, I placed it into the varibale.php file as you suggested, but it didn't work :( I looked for any other variable.php files I might have in my theme directory - but found none.
    What might be the problem?
    Can it conflict with the bheadrick's suggestion? (because I left it in my theme's functions.php file).
    What do you think?

  18. Sumim
    Member
    Posted 1 year ago #

    To Brad Smith:
    Thank you for your suggestion! I am currently looking at Register Plus Redux and New User Approve Plugins. As soon as I try one of them, I will post my review here.

  19. Ron Troyer
    Member
    Posted 12 months ago #

    Hi
    Like Brad I would like to hide ALL pricing - even when the user is logged in. The shopping cart would still function as an ordering tool but billed or quoted per other means.

    So I still want the add to cart button to be usable.

    Does anyone know how I could modify this code from bheadrick?
    I do not need the "Login or Register to see price"

    add_filter('woocommerce_get_price_html','members_only_price');
    function members_only_price($price){
    if(is_user_logged_in() ){
        return $price;
    }
    else return '<a href="' .get_permalink(woocommerce_get_page_id('myaccount')). '">Login</a> or <a href="'.site_url('/wp-login.php?action=register&redirect_to=' . get_permalink()).'">Register</a> to see price!';
    }
  20. Rican UK
    Member
    Posted 11 months ago #

    Hi,

    Linking back to the original piece of code provided by bheadrick. Its a great addition, and works a treat! The only little issue is that it only seems to work for simple products.

    We have many products on our site which are variable and require the user to select colour/size etc before it reveals the price and add to cart button. Is there anyway this code can be amended to take account for this? I really appreciate the posting of this code!

    I look forward to any replies...

    Rican UK

  21. jatt485
    Member
    Posted 11 months ago #

    bheadrick's code works fine to hide the price but is there any way to hide add to cart for the users that are not logged in?
    aimeevee's code doesnt seem to work

  22. sunfishdesign
    Member
    Posted 7 months ago #

    I tried the first code and it worked great (bheadrick). But it still shows the price in the "cart" - any idea how to get rid of that too. They want people to be able to add things to a cart but not see the price.

    thanks!

  23. editora
    Member
    Posted 7 months ago #

    hello, I just came across this post 'cause I'm searching how to display again prices in woocommerce.

    I'm trying to do a simple store for a book which has many covers' options. So I just needed the price to show once, not by every product.

    I did get to hide the prices, but then ALL the pricing (cart total, and subtotal as well) went away.

    As I'm really newby, I usually just use the display:none.
    But I've searched the woocommerce.css, my theme's style and so on and can't find where was the modification : /

    Does anyone can point which/where are the strings that control prices?

    the website is http://omundoculturaenatureza.com.br/?post_type=product

    thanks a lot for any help!

  24. chetan0412
    Member
    Posted 7 months ago #

    HI,

    Code

    add_filter('woocommerce_get_price_html','members_only_price');
    function members_only_price($price){
    if(is_user_logged_in() ){
        return $price;
    }
    else return '<a href="' .get_permalink(woocommerce_get_page_id('myaccount')). '">Login</a> or <a href="'.site_url('/wp-login.php?action=register&redirect_to=' . get_permalink()).'">Register</a> to see price!';
    }

    working fine , but if user add product in cart,than price is viaible in cart page . how to hide product in cart also???

  25. editora
    Member
    Posted 7 months ago #

  26. 2112
    Member
    Posted 6 months ago #

    OK thanks to all!!

    Its work for me the following:
    ( paste in the function.php )

    add_filter('woocommerce_get_price_html','members_only_price');
    function members_only_price($price){
    if(is_user_logged_in() ){
        return $price;
    }
    else return '<a href="' .get_permalink(woocommerce_get_page_id('myaccount')). '">Accede</a> o <a href="'.site_url('/wp-login.php?action=register&redirect_to=' . get_permalink()).'">RegĂ­strate</a> para ver precios!'.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 );
    }

    this hide price and add to cart button and all prices in site.. if I dont login of course..

  27. Rican UK
    Member
    Posted 6 months ago #

    Thanks 2112,

    That code works great for all products!

    Just a little query: I seem to be getting 'Login or Register to see price!1111'. Do you know what might be causing these 1111 to be appearing??

    Also, the short description/excerpt seems to have vanished. Is there some way to get this back?

    Thanks in advance!

    DS

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.