Two parts: what I did and what I want to do.
What I did. We wanted the price display to be other than the spread of [min-price – max-price] and have is say [“Starting at -” min-price]. This we accomplished with the following.:

    add_filter( 'woocommerce_variable_sale_price_html', 'hide_variable_max_price', PHP_INT_MAX, 2 );
add_filter( 'woocommerce_variable_price_html',      'hide_variable_max_price', PHP_INT_MAX, 2 );
function hide_variable_max_price( $price, $_product ) {
    $min_price_regular = $_product->get_variation_regular_price( 'min', true );
    $min_price_sale    = $_product->get_variation_sale_price( 'min', true );
    return ( $min_price_sale ==  $min_price_regular ) ?
       'Starting at '.  wc_price( $min_price_regular ) :
        '<del>'. wc_price( $min_price_regular ) . '</del>' . '<ins>' . wc_price( $min_price_sale ) . '</ins>';

What we want to do: many, but not all of our products are sold in pairs and singly for which we have product attributes of ‘pair’ and ‘single’. What is happening now with the min-price is grabbing the ‘single’ attribute since this is typically half of the lowest price pair. What we want is for the min-price for the lowest price pair. So my question is: can I edit the above code to exclude product_attribute ‘single’ from the resulting min-price? But also account for some products that use neither of these attributes?

I know this is about tweaking a plugin, but I thought this forum could handle this question since it seems to be a general WordPress php kinda question.

Read more here: How to exclude a specific woocommerce product_attribute in function?


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: