<?php get_header(); ?>
<?php global $qaleb;?>
<link rel='stylesheet' id='woocommerce_prettyPhoto_css-css'  href='<?php bloginfo('url'); ?>/wp-content/plugins/woocommerce/assets/css/prettyPhoto.css' type='text/css' media='all' />
<style>#commentform input[type="text"]{width: 100%;}</style>
<div class="container">
<section class="ap_main">
<div class="container inn">
<div class="ap_news">
<div class="content">
<header class="heding">
<?php if($qaleb['shop-like-ac']=='1'){?><div class="post_like"><?php echo get_simple_likes_button(get_the_ID()); ?></div><?php } ?>
<?php if($qaleb['shop-bread-ac']=='1'){?><div class="crumbs"><a href="<?php bloginfo('url'); ?>">خانه</a> <?php echo wc_get_product_category_list( $product->get_id(), ' ', '' . _n( '', '', count( $product->get_category_ids() ), 'woocommerce' ) . ' ', '' ); ?></div><?php } ?>
<h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
<ul class="news-detile">
<?php if($qaleb['single-shop-id-ac']=='1'){?><li><i class="fa fa-file-text-o"></i><span> شناسه محصول : <?php echo $product->get_sku(); ?></span></li><?php } ?>
<?php if($qaleb['single-shop-date-ac']=='1'){?><li><i class="fa fa-calendar"></i><span><?php the_time(' d F Y - G:i');  ?></span></li><?php } ?>
<li class="news-save">
<?php if($qaleb['single-shop-print']=='1'){?><a class="print" href="#" onclick='window.open("<?php the_permalink();?>?print=1", "printwin","left=200,top=200,width=820,height=550,toolbar=1,resizable=0,status=0,scrollbars=1");'></a><?php } ?>
<?php if($qaleb['single-shop-send']=='1'){?><?php echo direct_email('') ?><?php } ?>
</li>
<?php if($qaleb['single-shop-font']=='1'){?>
<li class="news-save">
<div class="fontsize">
<div class="plustext"><i class="fa fa-plus"></i></div>
<a class="size_reset"><i class="fa fa-pencil"></i></a> 
<div class="minustext"><i class="fa fa-minus"></i></div>
</div>
</li>
<?php } ?>
</ul>
</header>

<div class="shoping">

<div class="shop-right">
<?php if(get_post_meta($post->ID, '_sale_price', true)){ echo '<span class="shop-sale">حراج</span>'; } ?>	
	<div class="images">

		<?php
		if ( has_post_thumbnail() ) {

			$image_title 	= esc_attr( get_the_title( get_post_thumbnail_id() ) );
			$image_caption 	= get_post( get_post_thumbnail_id() )->post_excerpt;
			$image_link  	= wp_get_attachment_url( get_post_thumbnail_id() );
			$image       	= get_the_post_thumbnail( $post->ID, apply_filters( 'single_product_large_thumbnail_size', 'shop_single' ), array(
				'title'	=> $image_title,
				'alt'	=> $image_title
				) );

			$attachment_count = count( $product->get_gallery_attachment_ids() );

			if ( $attachment_count > 0 ) {
				$gallery = '[product-gallery]';
			} else {
				$gallery = '';
			}

			echo apply_filters( 'woocommerce_single_product_image_html', sprintf( '<a target="_blank" href="%s" itemprop="image" class="img_big woocommerce-main-image zoom" title="%s" data-rel="prettyPhoto' . $gallery . '">%s</a>', $image_link, $image_caption, $image ), $post->ID );

		} else {

			echo apply_filters( 'woocommerce_single_product_image_html', sprintf( '<img width="500" height="500" src="%s" alt="%s" />', wc_placeholder_img_src(), __( 'Placeholder', 'woocommerce' ) ), $post->ID );

		}
	?>

<?php
$attachment_ids = $product->get_gallery_attachment_ids();

if ( $attachment_ids ) {
	$loop 		= 0;
	$columns 	= apply_filters( 'woocommerce_product_thumbnails_columns', 3 );
	?>
	<div class="thumbnails <?php echo 'columns-' . $columns; ?>"><?php

		foreach ( $attachment_ids as $attachment_id ) {

			$classes = array( 'zoom' );

			if ( $loop == 0 || $loop % $columns == 0 )
				$classes[] = 'first';

			if ( ( $loop + 1 ) % $columns == 0 )
				$classes[] = 'laste';

			$image_link = wp_get_attachment_url( $attachment_id );

			if ( ! $image_link )
				continue;

			$image_title 	= esc_attr( get_the_title( $attachment_id ) );
			$image_caption 	= esc_attr( get_post_field( 'post_excerpt', $attachment_id ) );

			$image       = wp_get_attachment_image( $attachment_id, apply_filters( 'single_product_small_thumbnail_size', 'shop_thumbnail' ), 0, $attr = array(
				'title'	=> $image_title,
				'alt'	=> $image_title
				) );

			$image_class = esc_attr( implode( ' ', $classes ) );

			echo apply_filters( 'woocommerce_single_product_image_thumbnail_html', sprintf( '<a target="_blank" href="%s" class="%s" title="%s" data-rel="prettyPhoto[product-gallery]">%s</a>', $image_link, $image_class, $image_caption, $image ), $attachment_id, $post->ID, $image_class );

			$loop++;
		}

	?></div>
	<?php
}

?>

</div>

</div>
<div class="shop-left">

<?php if($qaleb['single-shop-prices-ac']=='1'){?>
<div class="prices"><?php woocommerce_template_loop_price() ?> تومان </div>
<?php } ?>
<?php
	$show_button_add_to_cart = true;
	$manage_stock = get_post_meta($post->ID, '_manage_stock', true);
	$stock = get_post_meta($post->ID, '_stock', true);
	$stock_status = get_post_meta($post->ID, '_stock_status', true);
	if( $manage_stock == 'yes' ) {
		if ( $stock <= 0 ) $show_button_add_to_cart = false ;
	}
	if ( $stock_status == 'outofstock' ) $show_button_add_to_cart = false ;
	?>
	<?php
	if( $show_button_add_to_cart ){
		echo '<div class="status_product_in_stock"> وضعیت محصول: <span style="color:#f00">موجود</span></div>';
	} else {
		echo '<div class="status_product_in_stock"> وضعیت محصول: <span style="color:#f00">ناموجود</span></div>';
	}
	?>



<?php
$has_row    = false;
$alt        = 1;
$attributes = $product->get_attributes();
if($attributes){
ob_start();

?>	
<?php
if ( $has_row ) {
	echo ob_get_clean();
} else {
	ob_end_clean();
}
}
?>	

<div class="add_to_cart"><?php woocommerce_template_loop_add_to_cart(); ?></div>
<div class="nav-lin"></div>
<?php if($qaleb['single-shop-category-ac']=='1'){?>	<tr><th> دسته بندی : </th><td><?php echo wc_get_product_category_list( $product->get_id(), ' / ', '' . _n( '', '', count( $product->get_category_ids() ), 'woocommerce' ) . ' ', '' ); ?></td></tr><?php } ?>
<div class="clearfix"></div>
<?php if($qaleb['single-shop-tags-ac']=='1'){?><tr><th> برچسب ها : </th><td><?php echo $product->get_tags( ' / ' ); ?></td></tr><?php } ?>	
</div>
</div>

<table class="shop_attributes">

	<?php if ( $product->enable_dimensions_display() ) : ?>
		<?php if ( $product->has_weight() ) : $has_row = true; ?>
			<tr class="<?php if ( ( $alt = $alt * -1 ) == 1 ) echo 'alt'; ?>">
				<th><?php _e( 'Weight', 'woocommerce' ) ?></th>
				<td class="product_weight"><?php echo $product->get_weight() . ' ' . esc_attr( get_option( 'woocommerce_weight_unit' ) ); ?></td>
			</tr>
		<?php endif; ?>

		<?php if ( $product->has_dimensions() ) : $has_row = true; ?>
			<tr class="<?php if ( ( $alt = $alt * -1 ) == 1 ) echo 'alt'; ?>">
				<th><?php _e( 'Dimensions', 'woocommerce' ) ?></th>
				<td class="product_dimensions"><?php echo $product->get_dimensions(); ?></td>
			</tr>
		<?php endif; ?>

	<?php endif; ?>

	<?php foreach ( $attributes as $attribute ) :
		if ( empty( $attribute['is_visible'] ) || ( $attribute['is_taxonomy'] && ! taxonomy_exists( $attribute['name'] ) ) ) {
			continue;
		} else {
			$has_row = true;
		}
		?>
		<tr class="<?php if ( ( $alt = $alt * -1 ) == 1 ) echo 'alt'; ?>">
			<th><?php echo wc_attribute_label( $attribute['name'] ); ?></th>
			<td><?php
				if ( $attribute['is_taxonomy'] ) {

					$values = wc_get_product_terms( $product->id, $attribute['name'], array( 'fields' => 'names' ) );
					echo apply_filters( 'woocommerce_attribute', wpautop( wptexturize( implode( ', ', $values ) ) ), $attribute, $values );

				} else {

					// Convert pipes to commas and display values
					$values = array_map( 'trim', explode( WC_DELIMITER, $attribute['value'] ) );
					echo apply_filters( 'woocommerce_attribute', wpautop( wptexturize( implode( ', ', $values ) ) ), $attribute, $values );

				}
			?></td>
		</tr>
	<?php endforeach; ?>
<?php if($qaleb['single-shop-sal-ac']=='1'){?><tr><th> تعداد فروش </th><td><?php global $product; $units_sold = get_post_meta( $product->id, 'total_sales', true ); echo ''. sprintf( __( '%s', 'woocommerce' ), $units_sold ).''; ?> فروش </td></tr><?php } ?>
<?php if($qaleb['single-shop-ratings-ac']=='1'){?><?php if($product->get_average_rating()){ ?>	<tr class=""><th> امتیاز  </th><td><?php echo $product->get_average_rating(); ?> از 5  <?php echo $product->get_rating_html(); ?> </td></tr>	<?php } ?><?php } ?>
</table>

<div class="entry">
<?php if ( have_posts() ) { while ( have_posts() ) {the_post(); ?>
<?php setPostViews(get_the_ID());?>
<?php the_content(); ?>
<?php } } ?>
</div>

<div class="post-link">
<?php if($qaleb['single-shop-link']=='1'){?><div class="short"><span><i class="fa fa-link"></i> لینک کوتاه : </span><b><?php echo wp_get_shortlink(); ?></b></div><?php } ?>
<?php if($qaleb['single-shop-social-ac']=='1'){?>
<ul class="social">
<li><a class="facebook tooltip tooltip-top" data-iro="اشتراک گذاری در فیسبوک" target="_blank" href="http://www.facebook.com/sharer/sharer.php?u=<?php the_permalink(); ?>" > <i class="fa fa-facebook"></i></a></li>
<li><a class="twitter tooltip tooltip-top" data-iro="اشتراک گذاری در تویتر" target="_blank" href="http://twitter.com/home?status=<?php the_permalink(); ?>"> <i class="fa fa-twitter"></i></a></li>
<li><a class="google-plus tooltip tooltip-top" data-iro="اشتراک گذاری در گوگل پلاس" target="_blank" href="http://plus.google.com/share?url=<?php the_permalink(); ?>"> <i class="fa fa-google-plus"></i></a></li>
<li><a class="linkedin tooltip tooltip-top" data-iro="اشتراک گذاری در لینکداین" target="_blank" href="https://www.linkedin.com/shareArticle?mini=true&amp;url=<?php the_permalink() ?>"> <i class="fa fa-linkedin"></i></a></li>
<li><a class="telegram tooltip tooltip-top" data-iro="اشتراک گذاری در تلگرام" target="_blank" href="https://telegram.me/share/url?url=<?php the_permalink(); ?>"> <i class="fa fa-paper-plane"></i></a></li>
<li><a class="whatsapp tooltip tooltip-top" data-iro="اشتراک گذاری در واتساپ"target="_blank" href="https://wa.me/?text=<?php the_permalink(); ?>"> <i class="fa fa-whatsapp"></i></a></li>
</ul> 
<?php } ?>
</div>
<div class="post-mata">
<ul>
<?php if($qaleb['singl-shop-user-ac']=='1'){?><li><i class="fa fa-user" aria-hidden="true"></i> ارسال توسط : <?php the_author_posts_link(); ?></li><?php } ?>
<?php if($qaleb['single-shop-view-ac']=='1'){?><li><i class="fa fa-eye" aria-hidden="true"></i> <?php echo getPostViews (get_the_ID()); ?></li><?php } ?>
<?php if($qaleb['singl-shop-comments-ac']=='1'){?><li><i class="fa fa-commenting-o" aria-hidden="true"></i>  <?php comments_popup_link('بدون دیدگاه', 'يک دیدگاه', '% دیدگاه'); ?></li><?php } ?>
</ul>
</div>
</div>
<div class="boxx">
<div class="tit">
<h4><span><?php echo $qaleb['single-comment-title']; ?></span></h4>
<?php if($qaleb['comments-1'] == '1'){?><strong><?php $comments_count = wp_count_comments(get_the_ID()); echo "مجموع دیدگاهها : " . $comments_count->total_comments; ?></strong><?php } ?>
<?php if($qaleb['comments-2'] == '1'){?><strong><?php $comments_count = wp_count_comments(get_the_ID()); echo "در انتظار بررسی : " . $comments_count->moderated; ?></strong><?php } ?>
<?php if($qaleb['comments-3'] == '1'){?><strong>انتشار یافته : <?php comments_number('0', '1', '%' );?></strong><?php } ?>
</div>
<div class="aa">
<div class="single_comments woocommerce">
<?php comments_template(); ?>
</div></div>
</div>
</div>
<div class="co-aside sidebar"><?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('shop') ) : ?><?php endif; ?></div>
<div class="co-ads sidebar"><?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('ads') ) : ?><?php endif; ?></div>
<div class="clearfix"></div>
</div>
</section>
<?php get_template_part('inc/relate-shop'); ?>
</div>
<script type='text/javascript' src='<?php bloginfo('url'); ?>/wp-content/plugins/woocommerce/assets/js/prettyPhoto/jquery.prettyPhoto.min.js'></script>
<script type='text/javascript' src='<?php bloginfo('url'); ?>/wp-content/plugins/woocommerce/assets/js/prettyPhoto/jquery.prettyPhoto.init.min.js'></script>
<?php get_footer(); ?>