-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsingle-product.php
238 lines (184 loc) · 10.6 KB
/
single-product.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
<?php
/**
* The template for displaying all single posts
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/#single-post
*
* @package WordPress
* @subpackage Twenty_Seventeen
* @since 1.0
* @version 1.0
*/
get_header(); ?>
<div class="wrap">
<div id="primary" class="content-area blog-content-area">
<main id="main" class="site-main" role="main">
<section class="content">
<?php sed_iott_breadcrumbs(); ?>
<?php
/* Start the Loop */
while ( have_posts() ) : the_post();
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<div class="row">
<div class="col-md-4">
<?php
$product_gallery = iott_get_field( 'iott_product_gallery' );
$product_gallery = is_string( $product_gallery ) && !empty( $product_gallery ) ? explode( "," , $product_gallery ) : $product_gallery;
$product_gallery = is_array( $product_gallery ) ? $product_gallery : array();
if ( '' !== get_the_post_thumbnail() ){
$post_thumbnail_id = get_post_thumbnail_id( $post_id );
array_unshift( $product_gallery , $post_thumbnail_id );
}
$product_gallery = array_filter( $product_gallery , 'absint' );
?>
<div class="single-product-thumbnails-slider">
<div class="slider-wrap">
<div class="carousel">
<?php
if( !empty( $product_gallery ) ) {
foreach ($product_gallery AS $attach_id ) {
$img = get_sed_attachment_image_html( $attach_id , "large" );
if ( ! $img ) {
$img = array();
$img['thumbnail'] = '<img class="sed-image-placeholder sed-image" src="' . sed_placeholder_img_src() . '" />';
}
?>
<div class="item">
<?php echo $img['thumbnail'];?>
</div>
<?php
}
}
?>
</div>
</div>
</div>
<div class="single-product-nav-slider">
<div class="slider-wrap">
<div class="carousel">
<?php
if( !empty( $product_gallery ) ) {
foreach ($product_gallery AS $attach_id ) {
$img = get_sed_attachment_image_html( $attach_id , "thumbnail" );
if ( ! $img ) {
$img = array();
$img['thumbnail'] = '<img class="sed-image-placeholder sed-image" src="' . sed_placeholder_img_src() . '" />';
}
?>
<div class="item">
<?php echo $img['thumbnail'];?>
</div>
<?php
}
}
?>
</div>
</div>
</div>
</div>
<div class="col-md-8">
<header class="entry-header">
<h3>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
<span><?php the_title(); ?></span>
<small><?php iott_the_field('subtitle'); ?></small>
</a>
</h3>
<?php $str = get_terms_string(get_the_ID(), 'product_category', 'دسته: ', ' '); ?>
<?php $term = get_the_terms(get_the_ID(), 'product_category')[0]->term_id; ?>
<div class="meta">
<?php echo $str; the_tags("برچسبها: ", "، "); ?>
</div>
</header>
<section class="entry-content">
<h3 class="sectionTitle">توضیحات محصول:</h3>
<div class="entry">
<?php the_content(); ?>
<?php echo do_shortcode("[apss_share]"); ?>
</div>
<?php if (iott_get_field('link_video')) { ?>
<div class="watchVideo">
<a href="<?php iott_the_field('link_video'); ?>" class="fancybox" data-fancybox-type="iframe">مشاهده ویدیو</a>
</div>
<?php } ?>
</section>
</div>
</div>
</article>
<?php
endwhile; // End of the loop.
?>
<?php
$related_products = (array)iott_get_field( 'related_products' );
$related_products = array_filter( $related_products );
if( !empty( $related_products ) ){
?>
<section class="productSections relatedProducts">
<h4 class="sectionTitle"><span>محصولات مرتبط</span></h4>
<div class="slider-wrap">
<div class="carousel">
<?php
$args = array(
'post_type' => 'product',
//'showposts' => 18,
'post__in' => $related_products,
'orderby' => 'post__in'
);
?>
<?php query_posts($args); while (have_posts()) : the_post(); ?>
<div class="item">
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
<?php if ('' !== get_the_post_thumbnail() && !is_single()) : ?>
<?php the_post_thumbnail('s1x1'); ?>
<?php endif; ?>
<div class="caption">
<h5><?php the_title(); ?><hr class="little-separator" /><span><?php iott_the_field('subtitle'); ?></span></h5>
<p><?php the_excerpt(); ?></p>
</div>
</a>
</div>
<?php endwhile; wp_reset_query(); ?>
</div>
</div>
</section>
<?php }
$suggestion_products = (array)iott_get_field( 'suggestion_products' );
$suggestion_products = array_filter( $suggestion_products );
if( !empty( $suggestion_products ) ){
?>
<section class="productSections selectedProducts">
<h4 class="sectionTitle"><span>محصولات پیشنهادی</span></h4>
<?php
$args = array(
'post_type' => 'product',
//'showposts' => 18,
'post__in' => $suggestion_products,
'orderby' => 'post__in'
);
?>
<div class="slider-wrap">
<div class="carousel" data-flickity='{"percentPosition": false, "rightToLeft": true, "cellAlign": "right", "autoPlay": 15000, "groupCells": true }'> <!-- "contain": true, "wrapAround": true, -->
<?php query_posts( $args ); while (have_posts()) : the_post(); ?>
<div class="item">
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
<?php if ('' !== get_the_post_thumbnail() && !is_single()) : ?>
<?php the_post_thumbnail('s1x1'); ?>
<?php endif; ?>
<div class="caption">
<h5><?php the_title(); ?><hr class="little-separator" /><span><?php iott_the_field('subtitle'); ?></span></h5>
<p><?php the_excerpt(); ?></p>
</div>
</a>
</div>
<?php endwhile; wp_reset_query(); ?>
</div>
</div>
</section>
<?php } ?>
</section>
</main><!-- #main -->
</div><!-- #primary -->
<?php get_sidebar(); ?>
</div><!-- .wrap -->
<?php get_footer();