رفتن به مطلب

آموزش ایجاد تب برای قسمت محصولات


پست های پیشنهاد شده

با سلام

من قالبم رو اختصاصی طراحی کردن و الان دسترسی به طراح ندارم

میخوام برای قسمت Single Product یک تب دیگه اضافه کنم

Capture.PNG

از YITH WooCommerce Tab Manager و Product Tab For WooCommerce هم استفاده کردم ولی باز تب رو نشون نمیده

این کد نویسی این بخش :

<?php
/**
 * The Template for displaying all single products
 *
 * This template can be overridden by copying it to yourtheme/woocommerce/single-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 	    http://docs.woothemes.com/document/template-structure/
 * @author 		WooThemes
 * @package 	WooCommerce/Templates
 * @version     1.6.4
 */

get_header();
the_post();
global $post, $product;
$_product = wc_get_product( get_the_id() ); 
if( function_exists('get_aps_groups') ) {
	$attr_groups = get_aps_groups();
	$attributes = get_aps_attributes();
} ?>

	<div class="container-el main-box">
	    <?php get_template_part('partials/notifications'); ?>
		
		<div class="box-inner row">
			<?php get_template_part('partials/breadcrumbs'); ?>
			<?php get_template_part('partials/woocommerce-messages'); ?>
			
			<div class="row" itemscope itemtype="<?php echo woocommerce_get_product_schema(); ?>">
				<?php 
				$attachment_ids = $product->get_gallery_attachment_ids();
				if( empty( $attachment_ids ) )
					$attachment_ids = array( get_post_thumbnail_id() );
				
				if( sizeof( $attachment_ids ) > 0 ) : ?>
					<div class="slider-pro col ltr">
						<div class="item-big row">
							<?php
							$thumb = wp_get_attachment_image_src( $attachment_ids[0], array(400,400) );
							$thumb = $thumb[0];
							$src = wp_get_attachment_image_src( $attachment_ids[0], 'full' );
							$src = $src[0]; ?>
							<a href="#product_gallery" title="<?php the_title_attribute(); ?>">
								<img style="display:block;" itemprop="image" src="<?php echo $thumb; ?>" data-imagezoom="<?php echo $src; ?>" data-magnification="4" data-zoomviewsize="[600,600]" alt="<?php the_title_attribute(); ?>" width="398" height="398">
							</a>
						</div>
						<div class="item-small row">
							<?php
							for( $i=0; $i <= 3; $i++ ) {
								echo '<a href="#product_gallery">';
								echo wp_get_attachment_image( $attachment_ids[$i], array(68,68) );
								echo '</a>';
							} 
							if( sizeof( $attachment_ids ) > 4 ) echo '<a href="#product_gallery">...</a>'; ?>
							
						</div>
					</div>
					
					<div id="product_gallery" class="login-pop product-gallery-popup" style="display:none;">
						<div class="tab-boxes row ltr">
							<ul class="tabs mCustomScrollbar go-left" data-mcs-theme="dark">
								<?php
								foreach( $attachment_ids as $index => $img ) {
									$active = $index === 0 ? ' class="active"' : '';
									echo "<li data-target=\"#gallery-attachment-$index\" $active>";
									echo wp_get_attachment_image( $img, array( 120,120 ) );
									echo '</li>';
								} ?>
							</ul>
							
							<div class="product-gallery-content col">
							
								<?php
								foreach( $attachment_ids as $index => $img ) {
									$active = $index === 0 ? ' class="active"' : '';
									echo "<div class=\"tab-content row\" id=\"gallery-attachment-$index\">";
									echo wp_get_attachment_image( $img, array(600,600) );
									echo '</div>';
								} ?>
								
							</div><!-- .product-gallery-content -->
						</div><!-- .tab-boxes -->
					</div><!-- #product_gallery -->
				<?php endif; ?>
				
				<div class="info-pro go-left">
					<?php
					/**
					 * woocommerce_single_product_summary hook
					 *
					 * @hooked woocommerce_template_single_title - 5
					 * @hooked woocommerce_template_single_price - 10
					 * @hooked woocommerce_template_single_excerpt - 20
					 * @hooked woocommerce_template_single_add_to_cart - 30
					 * @hooked woocommerce_template_single_meta - 40
					 * @hooked woocommerce_template_single_sharing - 50
					 */	
					do_action( 'woocommerce_single_product_summary' ); ?>
				</div>
				
				<meta itemprop="url" content="<?php the_permalink(); ?>" />
			</div>
			
			<div class="product-ds row">
				<?php if( function_exists('kk_star_ratings') ) : ?>
					<span class="star-pro go-left">امتیاز این محصول 
						<?php echo kk_star_ratings( get_the_id() ); ?>
					</span>
				<?php endif; ?>
			</div>
		</div>
	</div>
	
	
	<div class="main-box container-el tab-boxes">
	    <ul class="title-single-pro tabs row">
		    <li data-target="#baresi" class="active"><i class="fa fa-pencil-square-o fa fa-fw"></i> بررسی تخصصی محصول</li>
			<?php if( isset($attr_groups) && !empty($attr_groups) ) echo '<li data-target="#fani"><i class="fa fa-sliders fa fa-fw"></i></i> مشخصات فنی محصول</li>'; ?>
			<li data-target="#soalat"><i class="fa fa-comments  fa fa-fw"></i> نظرات و سوالات کاربران</li>
		</ul>
		
		<div id="baresi" class="single-wide post-content tab-content row">
			<?php the_content(); ?>
		</div>
		
		<?php if( isset($attr_groups) && !empty($attr_groups) ) : ?>
		
			<div id="fani" class="single-wide tab-content row">
				<?php
				// start foreach loop
				foreach ($attr_groups as $key => $group) {
					if ($group['display'] == 'yes') {
						// get post meta data by key
						$data = get_aps_product_attributes($post->ID, $key);
						
						$checkempty = array_filter( $data );
						
						// check if data is an array
						if ( !empty($checkempty) ) { ?>
							
							<span class="title-fani block"><?php echo $group['name']; ?></span>
							
							<?php  if( !empty( $attributes[$key] ) ) : ?>
							<table class="row">
								<?php foreach ($attributes[$key] as $attr_key => $attr_val) {
									// get attribute data
									$value = $data[$attr_key];
									if ( !empty($value) || $attr_val['type'] == 'check' ) {
										
										// check if value is date
										if ($attr_val['type'] == 'date') {
											$value = date('d F Y', strtotime($value));
										} elseif ($attr_val['type'] == 'check') {
											$value = ($value == 'Yes') ? '<i class="fa fa-check fa-lg"></i>' : '<i class="fa fa-times fa-lg"></i>';
										} ?>
										<tr>
											<td>
												<strong class="aps-term<?php if (!empty($attr_val['info'])) echo ' aps-tooltip'; ?>"><?php echo $attr_val['name']; ?></strong> 
												<?php if (!empty($attr_val['info'])) echo '<span class="aps-tooltip-data">' .$attr_val['info'] .'</span>'; ?>
											</td>
											
											<td>
												<?php echo nl2br($value); ?>
											</td>
										</tr>
									<?php }
								} ?>
							</table>
							<?php endif; ?>
						<?php }
					}
				} // end foreach loop ?>
				
			</div>
		<?php endif; ?>
		
		<div id="soalat" class="single-wide tab-content row">
			<?php
			if ( comments_open() || get_comments_number() )
				comments_template();
			wp_reset_postdata(); ?>
		</div>
	</div>
	
	<?php
	global $post;

	$cats = wp_get_post_terms( $post->ID, "product_cat" );
	foreach ( $cats as $cat ) {
		$cats_array[] .= $cat->term_id;
	}

	$tags = wp_get_post_terms( $post->ID, "product_tag" );
	foreach ( $tags as $tag ) {
		$tags_array[] .= $tag->term_id;
	}

	$related_posts = new WP_Query(
		array(
			'orderby' => 'rand',
			'posts_per_page' => 5,
			'post_type' => 'product',
			'post__not_in' => array($post->ID),
			'tax_query' => array(
				'relation' => 'OR',
				array(
						'taxonomy' => 'product_cat',
						'field' => 'id',
						'terms' => $cats_array
				),
				array(
						'taxonomy' => 'product_tag',
						'field' => 'id',
						'terms' => $tags_array
				)
			)
		)
	);

	if( $related_posts->have_posts() ) : ?>
		<div class="container-el">
			<div class="title-bot row"><span class="fa col">محصولات مشابه</span> <span class="en go-left">SIMILAR PRODUCTS</span></div>
			
			<div class="main-box row ltr slid-bot">
				<?php
				while( $related_posts->have_posts() ){
					$related_posts->the_post();
					get_template_part("content", "product");
				}
				wp_reset_postdata(); ?>
				
			</div>
		</div>
	<?php endif; ?>
	
	<?php the_terms( 0, 'product_tag', '<div class="tag-box container-el"><span>برچسب ها</span>', ', ', '</div>' ); ?>
	
<?php
get_footer();

 

هر کاری کردم نتونستم اضافه کنم لطفا کمکم میکنید ؟

 

لینک به ارسال

به گفتگو بپیوندید

هم اکنون می توانید مطلب خود را ارسال نمایید و بعداً ثبت نام کنید. اگر حساب کاربری دارید، برای ارسال با حساب کاربری خود اکنون وارد شوید .

مهمان
ارسال پاسخ به این موضوع ...

×   شما در حال چسباندن محتوایی با قالب بندی هستید.   حذف قالب بندی

  تنها استفاده از 75 اموجی مجاز می باشد.

×   لینک شما به صورت اتوماتیک جای گذاری شد.   نمایش به صورت لینک

×   محتوای قبلی شما بازگردانی شد.   پاک کردن محتوای ویرایشگر

×   شما مستقیما نمی توانید تصویر خود را قرار دهید. یا آن را اینجا بارگذاری کنید یا از یک URL قرار دهید.

×
×
  • اضافه کردن...