<?php
/**
 * The template for displaying product content within loops
 *
 * This template can be overridden by copying it to yourtheme/woocommerce/content-product.php.
 *
 * HOWEVER, on occasion WooCommerce will need to update template files and you
 * (the theme developer) will need to copy the new files to your theme to
 * maintain compatibility. We try to do this as little as possible, but it does
 * happen. When this occurs the version of the template file will be bumped and
 * the readme will list any important changes.
 *
 * @see     https://docs.woocommerce.com/document/template-structure/
 * @package WooCommerce/Templates
 * @version 3.6.0
 */

defined( 'ABSPATH' ) || exit;

global $product;

// Ensure visibility.
if ( empty( $product ) || ! $product->is_visible() ) {
	return;
}
?>
	<?php if ( $product->is_featured() ) { ?><div class="ribbon-featured"><?php if (get_theme_mod( 'charsoogh_featured_badge_title' )) : echo get_theme_mod( 'charsoogh_featured_badge_title'); else: echo __('Featured' ,'charsoogh'); endif; ?></div><?php } ?>
				<div class="wrapper">
					<span class="favorite_<?php echo $post->ID; ?> bookmark" data-toggle="tooltip" data-placement="top" title="<?php _e('Add to Featured' , 'charsoogh'); ?>"><?php _e('Add to Featured' , 'charsoogh'); ?></span>
					<?php if (get_theme_mod( 'charsoogh_visit_ad_show') != 'no') : ?>
					<span class="ad_visit"><?php echo getPostViews($post->ID); ?></span>
					<?php endif; ?>
							<div class="image">
								<?php if(get_the_terms( $post->ID, 'city_categories')){ ?>
								<h4 class="location">
									<?php
									$terms = wp_get_post_terms( $post->ID, 'city_categories', array( 'order' => 'DESC') );
									if(is_rtl()):
									$sep = ' <i class="fa fa-angle-left" aria-hidden="true"></i> ';
									else:
									$sep = ' <i class="fa fa-angle-right" aria-hidden="true"></i> ';
									endif;
									foreach ( $terms as $term ) {
										$url = get_term_link($term->slug, 'city_categories');
										if ($term->parent == 0){echo "<a href='{$url}'>{$term->name}</a>";}
									}
									foreach ( $terms as $term ) {
										$url = get_term_link($term->slug, 'city_categories');
										if ($term->parent != 0){echo $sep . "<a href='{$url}'>{$term->name}</a>";}
									}
									?>
								</h4>
							<?php } ?>
									<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" class="title">
										<?php woocommerce_template_loop_product_thumbnail(); ?>
										 </a>
							</div>
							<?php woocommerce_template_loop_price(); ?>
							<div class="meta">
								<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" class="title">
									<h2><?php the_title(); ?></h2>
								</a>
								<figure>
									<?php if (empty(get_theme_mod( 'charsoogh_date_type')) || get_theme_mod( 'charsoogh_date_type') == 'advanced') : ?>
										<i class="fa fa-calendar-o"></i><?php echo human_time_diff( get_the_time('U'), current_time('timestamp') ) . __(' Ago' , 'charsoogh'); ?>
									<?php else: ?>
										<i class="fa fa-calendar-o"></i><?php echo get_the_date(); ?>
									<?php endif; ?>
								</figure>
									<figure>
											<i class="fa fa-folder-open-o"></i><?php the_terms( $post->ID, 'product_cat', '', " ", '' );?>
									</figure>
									<script> user_favorite(<?php echo $post->ID; ?>);</script>
							</div>
							<!--end meta-->
							<!--end description-->
					</div>
