• Hi,

    I’ve added price variables for certain products on my site but rather than price displaying as it does now e.g £50.00–£204.99 I’d like it to just display the highest price.

    This is due to the low price being an option of putting down a deposit for the product whereas the high price is actually how much it costs.

    What can I add to the functions.php that will show the high price only?

    Cheers

    Stu

    edit – Code for displaying just the lowest price would be useful to have too.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Lowest price:
    https://snippet.fm/snippets/hide-max-price-for-variable-products-in-woocommerce/
    Hopefully you can tweak the snippet to show the highest price.

    Thread Starter ChipmunkDesign

    (@chipmunkdesign)

    This is where my lack of coding knowledge comes in. Made an attempt to amend that but didn’t go as planned! heh

    
    // hide min price
    add_filter( 'woocommerce_variable_sale_price_html', 'hide_variable_min_price', PHP_INT_MAX, 2 );
    add_filter( 'woocommerce_variable_price_html',      'hide_variable_min_price', PHP_INT_MAX, 2 );
    function hide_variable_min_price( $price, $_product ) {
        $max_price_regular = $_product->get_variation_regular_price( 'max', true );
        $max_price_sale    = $_product->get_variation_sale_price( 'max', true );
        return ( $max_price_sale == $max_price_regular ) ?
            wc_price( $max_price_regular ) :
            '<del>' . wc_price( $max_price_regular ) . '</del>' . '<ins>' . wc_price( $max_price_sale ) . '</ins>';
    }
    

    If this code is the first thing in functions.php, it must start with

    
    <?php
    
    Thread Starter ChipmunkDesign

    (@chipmunkdesign)

    Great stuff – thanks so much! Perfect for what I need.

    Stu

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Disable minimum price from price variable’ is closed to new replies.