Files
Fakel-Gym/template-parts/la-components/blocks/club-cards-block/club-cards-block.php
T
2025-07-08 14:21:19 +03:00

155 lines
7.9 KiB
PHP

<?php
/**
* Блок с клубными картами
*/
$block_id = 'club-cards-' . $block['id'];
$class_name = 'club-cards-block';
if (!empty($block['className'])) {
$class_name .= ' ' . $block['className'];
}
if (!empty($block['align'])) {
$class_name .= ' align' . $block['align'];
}
if (!function_exists('get_club_cards_for_current_language')) {
function get_club_cards_for_current_language()
{
$current_lang = pll_current_language();
$args = array(
'post_type' => 'club-card',
'posts_per_page' => -1,
'lang' => $current_lang,
'post_status' => 'publish',
'sort' => 'menu_order',
'order' => 'ASC',
);
return get_posts($args);
}
}
$cards = get_club_cards_for_current_language();
$heading = get_field('heading', $block['id']);
$room = get_current_room();
if ($room === 'fitness') {
} else {
$section_classes = 'bg-cover bg-center bg-no-repeat';
$bg_image = get_template_directory_uri() . '/assets/images/hero-bg.png';
$style_attr = 'style="background-image: url(' . esc_url($bg_image) . ')"';
}
?>
<section id="<?php echo esc_attr($block_id); ?>" class="py-[96px] <?php echo esc_attr($section_classes); ?>" <?php echo $style_attr; ?>>
<div class="container mx-auto">
<?php if ($cards): ?>
<div class="mt-[24px] grid grid-cols-3 gap-[24px]">
<?php if (is_front_page()): ?>
<?php if ($heading) : ?>
<div class="flex flex-col gap-[16px] [&>img]:w-[294px] mt-[28px]">
<h2 class="dark:text-[#fff] text-[40px] leading-[120%] font-[500]"><?php echo esc_html($heading); ?></h2>
<?php display_icon(get_current_room() === 'gym' ? 'dark_logo_name' : 'light_logo_name'); ?>
</div>
<?php endif; ?>
<?php endif; ?>
<?php foreach ($cards as $card): ?>
<div class="bg-[#ffffff] rounded-[12px] p-[28px] pb-[16px] h-[258px] shadow-[0_2px_32px_0_rgba(16,_15,_15,_0.03)]">
<div class="flex flex-col h-full">
<div class="flex gap-[16px] items-center"> <?php
$card_image = get_field('image', $card->ID);
if ($card_image): ?>
<div class="overflow-hidden w-[32px] h-[32px]">
<img src="<?php echo esc_url($card_image['url']); ?>"
alt="<?php echo esc_attr($card_image['alt']); ?>"
class="w-full h-full object-cover"/>
</div>
<?php endif; ?>
<?php $card_heading = get_field('heading', $card->ID); ?>
<?php if ($card_heading): ?>
<h3 class="text-[24px] font-[600] leading-[125%]">
<?php echo esc_html($card_heading); ?>
</h3>
<?php endif; ?></div>
<?php $card_description = get_field('description', $card->ID); ?>
<?php if ($card_description): ?>
<div class="text-[16px] leading-[145%] font-[500] mt-[16px]">
<?php echo wp_kses_post($card_description); ?>
</div>
<?php endif; ?>
<div class="flex mt-auto pt-[16px] border-t border-t-[#f1f1f1] justify-between items-center gap-[12px] flex-wrap">
<?php $popup_button = get_field('popup_button', $card->ID); ?>
<?php $card_price = get_field('price', $card->ID) ?: ($card_prices['1_month']['day'] ?? ''); ?>
<?php
$card_prices = [];
if (have_rows('card_prices', $card->ID)) {
while (have_rows('card_prices', $card->ID)) {
the_row();
$periods = ['1_month', '3_month', '6_month', '12_month'];
foreach ($periods as $period) {
if (have_rows($period)) {
while (have_rows($period)) {
the_row();
$card_prices[$period] = [
'full' => get_sub_field('full'),
'day' => get_sub_field('day')
];
}
}
}
}
}
?>
<?php
$card_time = [];
if (have_rows('time', $card->ID)) {
while (have_rows('time', $card->ID)) {
the_row();
$card_time[] = [
'normal_days' => get_sub_field('normal_days'),
'vacation_days' => get_sub_field('vacation_days')
];
}
}
?>
<div>
<button
data-modal="club-card"
data-card-id="<?php echo $card->ID; ?>"
data-card-title="<?php echo esc_attr($card_heading); ?>"
data-card-prices='<?php echo esc_attr(json_encode($card_prices)); ?>'
data-card-time='<?php echo esc_attr(json_encode($card_time));
?>'
class="red-gradient-hover cursor-pointer flex text-[#f8f8f8] text-[18px] text-[#fff] font-[600] justify-center h-[59px] w-[160px] rounded-[90px] flex items-center">
<?php echo 'Оформить' ?>
</button>
</div>
<?php if ($card_price): ?>
<div class="flex items-center text-[20px] font-[600] leading-[125%]">
от 
<div class="rounded-[32px] px-[12px] h-[36px] flex items-center bg-[linear-gradient(90deg,_rgba(43,_44,_53,_0.06)_39.42%,_rgba(110,_121,_150,_0.06)_92.9%)]">
<span class="bg-[linear-gradient(90deg,_#2b2c35_67.31%,_#4f5870_92.9%)] text-[24px] flex items-center justify-center font-[600] bg-clip-text text-transparent"> <?php echo esc_html($card_price); ?> ₽ </span>
</div>
 в день
</div>
<?php endif; ?>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>
</section>