<div class="tariff_item-inner">
<div class="tariff_item-price">
<?
$basePrice = $value['courses-page_rates_item_base-price'];
$discountPrice = $value['courses-page_rates_item_discount-price'];
global $product;
if ($product->product_type == 'variable') {
$available_variations = $product->get_available_variations();
$variation_id = $available_variations[$key]['variation_id']; // Getting the variable id of just the 1st product. You can loop $available_variations to get info about each variation.
$variable_product1 = new WC_Product_Variation($variation_id);
$regular_price = $variable_product1->regular_price;
$sales_price = $variable_product1->sale_price;
$today_day_date = date('Ymd');
$variation = wc_get_product($variation_id);
$sales_price_to = $variation->get_date_on_sale_to();
$sales_price_from = $variation->get_date_on_sale_from();
$have_sale_date = false;
print($sales_price_to);
echo "---<br/>---";
print($sales_price_from);
if (!empty($sales_price_to) && !empty($variation)) {
if (!empty($sales_price_to)) {
$dati[$key] = strtotime($sales_price_to);
$dateExpired = date_i18n("Ymd", min($dati));
if ($today_day_date <= $dateExpired) {
$have_sale_date = true;
// print_r($variation);
echo " <br/> " .$key. " <br/> ";
$sales_price_to = "";
// $tekst = "";
// $dati[$n] = "";
echo "<br/>" . $dateExpired . " <br/>-<br/> " . $today_day_date . "<br/>";
} elseif ($today_day_date >= $dateExpired) {
// $regular_price = "";
echo "<br/>" . $dateExpired . " <br/>-<br/> " . $today_day_date . "<br/>";
}
}
// print_r($variation);
}
}
if ($have_sale_date && $today_day_date <= $dateExpired) { ?>
<? if (!empty($regular_price) && (empty($sales_price) || $sales_price == 0)) { ?>
<div class="tariff_item-price_new">
<? print_r($regular_price); ?> руб.
</div>
<? } elseif (!empty($regular_price) && !empty($sales_price)) { ?>
<div class="tariff_item-price_old">
<? print_r($regular_price); ?>
</div>
<div class="tariff_item-price_new">
<? print_r($sales_price); ?> руб.
</div>
<? } ?>
<? } else { ?>
<? if (!empty($regular_price) && (empty($sales_price) || $sales_price == 0)) { ?>
<div class="tariff_item-price_new">
<? print_r($regular_price); ?> руб.
</div>
<? } elseif (!empty($regular_price) && !empty($sales_price)) { ?>
<? if (!$have_sale_date && $today_day_date <= $dateExpired) { ?>
<div class="tariff_item-price_old">
<? print_r($regular_price); ?>
</div>
<? }
else { ?>
<div class="tariff_item-price_new">
<? print_r($regular_price ); ?> руб.
</div>
<? } ?>
<? }
} ?>
</div>
<? woocommerce_variable_add_to_cart(); ?>
</form>
</div>