Viewing 15 replies - 1 through 15 (of 26 total)
  • 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!';
    }
    Thread Starter MaddTechWF

    (@maddtechwf)

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

    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!';

    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

    it goes in your theme’s functions.php

    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

    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 πŸ™‚

    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',);

    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?

    aimeevee

    (@aimeevee)

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

    Coen Jacobs

    (@coenjacobs)

    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.

    aimeevee

    (@aimeevee)

    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

    Sumim

    (@sumim)

    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.

    Brad Smith

    (@bradsmith)

    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=

    Thread Starter MaddTechWF

    (@maddtechwf)

    @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?

Viewing 15 replies - 1 through 15 (of 26 total)
  • The topic ‘Hide Prices’ is closed to new replies.