Home Forums WoodMart support forum How to hide "External Only" products price?

How to hide "External Only" products price?

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #69475

    jodyshop
    Participant

    Hi,
    I have this code, which hides all prices from the entire website pages, but I want to only hide the external ones and keep the regular products prices intact.

    Here is the “Hide all code”

    // Hide All Product Prices
    add_filter( 'woocommerce_variable_sale_price_html', 'remove_prices', 10, 2 );
    add_filter( 'woocommerce_variable_price_html', 'remove_prices', 10, 2 );
    add_filter( 'woocommerce_get_price_html', 'remove_prices', 10, 2 );
     
    function remove_prices( $price, $product ) {
    $price = '';
    return $price;
    }

    Can you please help me how to accomplish that?

    Thank you

    #69479

    jodyshop
    Participant

    Hi, again

    Thanks for your consideration but, I have resolved the issue myself (as usual) 🙂

    here is the solution for anyone having the same issue…

    // Hide External Products Only Prices
    add_filter( 'woocommerce_variable_sale_price_html', 'woocommerce_remove_prices', 10, 2 );
    add_filter( 'woocommerce_variable_price_html', 'woocommerce_remove_prices', 10, 2 );
    add_filter( 'woocommerce_get_price_html', 'woocommerce_remove_prices', 10, 2 );
    function woocommerce_remove_prices( $price, $product ) {
        if( $product->is_type( 'external' ))
            $price = '';
            //$price = ' <a href='. esc_url( $product->get_product_url() ) .' target=_blank>Check Price</a> ';
    
        return $price;
    }

    The above code hides all “external product prices only) and keep the regular variable product prices intact. Also, you can choose to replace the price space with ” ” empty space, or with external product link.

    Just comment and uncomment the $price = ”; section.

    Thank you

    #69483

    jodyshop
    Participant

    Hi,
    Why do I need to hide the external product prices?

    Well, Recently I get tons of emails from customers blaming me about different prices they see on my Jodyshop website, and when they redirected to Buy from Amazon they find a different price (sometimes completely another price).

    Some customers called me a cheater ):

    Sure, I keep the entire prices updated every 3 days, but when I check personally, I find either a different price (even after product synced with Amazon).

    Anyway, now the prices are hidden for external products or affiliate products (so the customer can see he today’s fresh price).

    But I kept the other products prices intact! Why?

    Well, my Jodyshop is a tiny online marketplace, where sellers/vendors can register an account and start selling on my website (based on commission).

    Here are the final 2 products look:
    – External = without a price
    – Variable = with a price.

    Check Here

    Thanks for your time reading this ):
    Have a nice WordPress Coding 🙂

    #69497

    Hello,

    By default, WooCommerce does not have the option to hide price for one product type and show for another one.

    Does your external product require “Add to cart button”? If no, you can just leave the price filed empty.

    If you need “Add to cart button” you can hide the price with custom CSS which is added only in the certain product. http://prntscr.com/kbm94v This method, however, does not hide the price in shop page.

    Best Regards

    #69568

    jodyshop
    Participant

    So, you’re trying to say that I am brilliant? I have done what I wanted.

    You can check this page:
    https://www.jodyshop.com/featured-products/

    There are 2 different types of products: External and Variable one with the price shown and the other with the price hidden 🙂

    Keep it secret
    Ops, it’s not in the Private Content section 🙂

    #69576

    You have solved your issue, haven’t you? If you have any questions please feel free to contact us.

    Best Regards

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

The topic ‘How to hide "External Only" products price?’ is closed to new replies.