<?php
/**
* Template Name: Product categories Page
* Template Post Type: page
*
* @package
*/
get_header();
$pc_page_subtitle = get_field( 'pc_page_subtitle' );
$product_cat_description_title = get_field( 'product_cat_description_title' );
$products_limit = get_field( 'products_limit' ) ?: 8;
?>
<main id="primary" class="site-main">
<?php while ( have_posts() ) : the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<div class="container">
<?php get_template_part( 'template-parts/common/breadcrumbs' ); ?>
<header class="woocommerce-products-header">
<?php if ( $pc_page_subtitle ) : ?>
<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
<div class="archive-description">
<p class="text-accent"><?php echo esc_html( $pc_page_subtitle ) ?></p>
</div>
<?php else: ?>
<?php the_title( '<h1 class="entry-title title-decore">', '</h1>' ); ?>
<?php endif; ?>
</header>
<?php if ( have_rows( 'product_cats' ) ) : ?>
<div class="categories-anchor-wrapper">
<?php while ( have_rows( 'product_cats' ) ) :
the_row();
$term = get_sub_field('product_cat');
?>
<?php if( $term->count > 0 ): ?>
<a href="#id-<?php echo esc_html( $term->slug ); ?>" class="scroll-to"><?php echo esc_html( $term->name ); ?></a>
<?php endif; ?>
<?php endwhile; ?>
</div>
<?php endif; ?>
<?php if ( have_rows( 'product_cats' ) ) : ?>
<div class="product-categories-wrapper">
<?php while ( have_rows( 'product_cats' ) ) :
the_row();
$term = get_sub_field('product_cat');
?>
<?php if( $term->count > 0 ): ?>
<div class="product-categories-block" id="id-<?php echo esc_html( $term->slug ); ?>">
<div class="products-wrapper">
<?php echo do_shortcode( '[products limit="'. $products_limit .'" columns="4" category="'. $term->slug .'"]' ); ?>
</div>
<?php if (0) : ?>
<div class="product-categories-footer">
<a href="<?php echo esc_url( get_term_link( $term ) ); ?>" class="product-categories-footer-link">
<?php echo esc_html( 'More ', 'rocketfame' ); ?>
<?php echo esc_html( $term->name ); ?>
</a>
</div>
<?php endif; ?>
</div>
<?php endif; ?>
<?php endwhile; ?>
</div>
<?php endif; ?>
</div>
</article>
<?php endwhile; ?>
</main>
<?php get_footer(); ?>