display default variation price Woocommerce products

I need to show default variation price in Woocommerce product.

I find this post and code works. –> Woocommerce Show default variation price

but thre is a problem : the backend is too slowly and the product page get error 504 gateway because the script think too long… the is any alternative solutions ?

add_filter('woocommerce_variable_price_html', 'custom_variation_price', 10, 

function custom_variation_price( $price, $product ) {

    foreach($product->get_available_variations() as $pav){
        foreach($product->get_variation_default_attributes() as $defkey=>$defval){
            $price = $pav['display_price'];         

    return woocommerce_price($price);


Read more here: display default variation price Woocommerce products

Leave a Reply

Your email address will not be published. Required fields are marked *