<?php

$category_args = array(
    'hide_empty' => false,
);

if (is_shop()) {
	$category_args['parent'] = 0;
} elseif (is_product_category() && get_queried_object()->term_id != 0) {
	$category_args['parent'] = get_queried_object()->term_id;
}

$product_categories = get_terms( 'product_cat', $category_args );
?>
<?php if ($product_categories) : ?>
<div class="product-filter-section">
	<div class="ui vertical basic very padded segment woocommerce-category-menu">
		<div class="ui secondary compact large menu woocommerce-filder-menu">
		<?php foreach ($product_categories as $key => $category) : ?>
				<a href="<?php echo get_term_link($category) ?>" class="item"><?php echo esc_html($category->name); ?></a>
		<?php endforeach; ?>
		</div>
	</div>

	<div class="ui right aligned vertical basic very padded segment woocommerce-category-filter">
		<div class="ui selection fluid dropdown large input woocommerce-filter-dropdown">
			<div class="text"><?php esc_html_e('Categories', 'campoal') ?></div>
			<i class="dropdown icon"></i>
				<div class="menu">
				<?php foreach ($product_categories as $key => $category) : ?>
					<a href="<?php echo get_term_link($category) ?>" class="item"><?php echo esc_html($category->name); ?></a>
				<?php endforeach; ?>
				</div>
		</div>
	</div>
</div>
<?php else : ?>
	<div class="ui hidden divider"></div>
<?php endif; ?>
