<?php 
/**
 * Product Categories Template
 */
?>
<div id="<?php echo esc_attr($id); ?>" class="<?php echo esc_attr( $class ); ?>">
	<?php if( ! empty( $heading ) ){ ?>
		<div class="section-heading">			
			<h2><?php echo esc_html( $heading ); ?></h2>
			<?php if( $show_view_more_button ){ ?>
				<div class="view-all-btn">
					<a <?php echo implode(' ', $view_all_btn );?> ><?php echo esc_html( $view_more_button_text ); ?></a>
				</div>
			<?php } ?>
		</div>
	<?php } ?>
	<div class="section-content <?php echo esc_attr( $section_class ); ?>">
		<div class="products <?php echo esc_attr( $grid_class ); ?>" <?php if( ! empty( $slider_options ) ){ echo 'data-slider_options="'.esc_attr( $slider_options ).'"';  } ?> >
			<?php if ( $product_categories ) {
				$total_categories = count( $product_categories );
				foreach ( $product_categories as $cat ) {
					$cate_link = get_term_link( $cat ); ?>
					<div class="product-category<?php echo esc_attr( $column_class ); ?>">
						<div class="pls-category-inner">
							<div class="pls-category-image">
								<a href="<?php echo esc_url( $cate_link ); ?>">	
									<?php $thumbnail_id = get_term_meta( $cat->term_id, 'thumbnail_id', true );
									$catalog_img = wp_get_attachment_image_src( $thumbnail_id, $image_size );
									if ( ! empty( $catalog_img ) ) {
										$attribute 			= array();
										$attribute['alt'] 	= esc_html( $cat->name );
										echo pls_get_image_html( $thumbnail_id, $image_size, '', $attribute ); 
									}else{ ?>
										<img src="<?php echo esc_url( PLS_CORE_URL.'assets/images/product-placeholder.jpg' ); ?>" alt="<?php esc_html($cat->name ); ?>"/>
									<?php } ?>
								</a>
							</div>
							<?php if( $style == '1' ) { ?>
								<div class="pls-category-content">
									<a href="<?php echo esc_url( $cate_link ); ?>">
										<div class="pls-category-title"><?php echo esc_html( $cat->name ); ?></div>
										<?php if( $show_count ){ ?>
											<div class="pls-product-count-wrap">
												<span class="product-count"><?php printf( _n( '%d Item', '%d Items', $cat->count, 'modave-core' ), $cat->count ); ?></span>
												<span class="pls-category-arrow"></span>
											</div>
										<?php } ?>
									</a>
								</div>
							<?php } elseif( $style == '2' ) { ?>
								<div class="pls-category-thumb-content">
									<div class="category-title">
										<a href="<?php echo esc_url( $cate_link ); ?>">
										<?php echo esc_html($cat->name); ?>
										</a>
									</div>
									<?php if( $show_count == 'yes' ){ ?>
										<span class="product-count"><?php printf( _n( '%d Item', '%d Items', $cat->count, 'modave-core' ), $cat->count ); ?></span>
									<?php } ?>
								</div>
							<?php } elseif( $style == '3' ) { ?>
								<div class="pls-category-thumb-content">
									<div class="category-title">
										<a href="<?php echo esc_url( $cate_link ); ?>">
											<?php echo esc_html($cat->name); ?>
										</a>
									<?php if( $show_count == 'yes' ){ ?>
										<span class="product-count"><?php printf( _n( '%d Item', '%d Items', $cat->count, 'modave-core' ), $cat->count ); ?></span>
									<?php } ?>
									</div>
									<a class="button" href="<?php echo esc_url( $cate_link ); ?>"><?php esc_html_e( 'Shop Now', 'modave-core' ) ?></a>
								</div>
							<?php } ?>
						</div>
					</div>
					<?php
				}
			} ?>
		</div>
	</div>
</div>