Как извлечь цену выбранного вариативного товара?

На сайте есть вариативные товары, мне нужно извлечь цену выбранной вариации товара и передать её методом POST при нажатии кнопки "Купить в рассрочку". Я прочитал много информации в интернете, но не нашёл ответ на свой вопрос. С простыми товарами проблем нет, не знаю как извлечь цену на выбранный товар. Помогите, как это сделать?

    $product = wc_get_product( get_the_id());

if( is_a( $product, 'WC_Product' ) || ! empty( $product ) ) {
    
    //* 1. Variable product (min and max)
    if ( $product->is_type('variable') ){
        $available_variations = $product->get_available_variations();
        $price_min = $product->get_variation_price('min'); // Float number
        $price_max = $product->get_variation_price('max'); // Float number

        $formatted_price_range = $product->get_price_html(); // Html formatted price range  
        
        $available_variations[0]->display_price;
        $available_variations[0]->display_regular_price;
        
        $deadline = 12;
        $rate = 25;

        $rate_sum = ($price_min / 100) * $rate;
        $total_sum = $price_min + $rate_sum;
        $base_per_month = $total_sum / $deadline;   
        $base_per_month_r = round($base_per_month);
        $total_sum_r = round($total_sum);
        
    } 

    // 2. Single product
    elseif ( $product->is_type('simple') ){
        $price = $product->get_price(); // Float number

        $formatted_price = $product->get_price_html(); // Html formatted price range
        
        $deadline = 12;
        $rate = 25;

        $rate_sum = ($price / 100) * $rate;
        $total_sum = $price + $rate_sum;
        $base_per_month = $total_sum / $deadline;   
        $base_per_month_r = round($base_per_month);
        $total_sum_r = round($total_sum);
    }
    else {
        echo "product is empty";
    }
}

?>
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content position-relative">
<div class="modal-header"><strong>Купить в рассрочку</strong></div>
<div class="modal-body">
<h3>Через MegaDream</h3>
<table class="table">
<thead>
<tr>
<th class="col" style="width: 33%;">Оплата за месяц</th>
<th class="col" style="width: 33%;">Срок (месяц)</th>
<th class="col" style="width: 33%;">Общая сумма</th>
</tr>
</thead>
<tbody>
<tr>
<td><b id="month_credit" style="color: #fe4f19; font-weight: 800;"><?php echo number_format($base_per_month_r, 0, '.', ' ');?></b></td>
<td style="text-align: left;"><b style="color: #fe4f19; font-weight: 800;">12</b></td>
<td><b id="total_credit" style="color: #fe4f19; font-weight: 800;"><?php echo number_format($total_sum_r, 0, '.', ' '); ?></b></td>
</tr>
</tbody>
</table>
По вопросам получения товаров в рассрочку, звоните по номеру <strong>+998(99) 351-71-40</strong>
</div>
<div class="modal-footer"><a class="btn btn-primary" style="background-color: #457f33; color: white; float: right; margin-top: 20px;" href="tel:+998993517140" type="button">Позвонить</a></div>
</div>
</div>

Ответы (0 шт):