Display second min variation price of a variable Product in WooCommerce 3

Viewed 1120

I'm using the following script:

add_filter('woocommerce_variable_price_html', 'custom_variation_price', 10, 2);

function custom_variation_price( $price, $product ) {

$price = '';

if ( !$product->min_variation_price || $product->min_variation_price !== $product->max_variation_price ) {
    $price .= '<span style="display:none;" class="not-from">v.a. ' . _x('', 'min_price', 'woocommerce') . ' </span>';

    $price .= woocommerce_price($product->get_price());
}

return $price;
}

It does show the min variation price at this moment. I want to create the following:

  • If the min price is 0,00, then show the 2nd product variation price.

E.g.: Product X has 3 different variations: 1 (€0,00), 2 (€5,00), 3 (€15,00). If the variation price is 0,00, then show second price variation, €5,00.

1 Answers
Related