-
Notifications
You must be signed in to change notification settings - Fork 0
/
page.php
232 lines (177 loc) · 6.34 KB
/
page.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
<?php
get_header() ?>
<?php
$filter = "";
if (isset($_POST['btn_filter'])) {
$filter = $_POST['btn_filter'];
} ?>
<?php
$args = array('post_type' => 'product');
$loop = new WP_Query($args);
if ($loop->have_posts()):
$loop->the_post();
global $product;
$category = get_queried_object();
$category_id = $category->term_id;
$category_name = $category->name;
endif;
$args = array(
'post_type' => 'product',
'post_status' => 'publish',
'posts_per_page' => -1,
'ignore_sticky_posts' => 1,
'tax_query' => array(
array(
'taxonomy' => 'product_cat',
'field' => 'term_id', //This is optional, as it defaults to 'term_id'
'terms' => $category_id,
'operator' => 'IN' // Possible values are 'IN', 'NOT IN', 'AND'.
),
array(
'taxonomy' => 'product_visibility',
'field' => 'slug',
'terms' => 'exclude-from-catalog', // Possibly 'exclude-from-search' too
'operator' => 'NOT IN'
)
)
);
$products = new WP_Query($args);
$arr_size = [];
$arr_zekhamat = [];
$arr_sizemaftol = [];
$arr_scale = [];
$arr_standard = [];
if ($products->have_posts()):
while ($products->have_posts()):
$products->the_post();
global $product;
$item = array_shift(wc_get_product_terms($product->id, 'pa_size', 'name'));
if (!empty($item)) {
$arr_size[] = $item;
}
$item = array_shift(wc_get_product_terms($product->id, 'pa_zekhamat', 'name'));
if (!empty($item)) {
$arr_zekhamat[] = $item;
}
$item = array_shift(wc_get_product_terms($product->id, 'pa_maftolsize', 'name'));
if (!empty($item)) {
$arr_sizemaftol[] = $item;
}
$item = array_shift(wc_get_product_terms($product->id, 'pa_scale', 'name'));
if (!empty($item)) {
$arr_scale[] = $item;
}
$item = array_shift(wc_get_product_terms($product->id, 'pa_standard', 'name'));
if (!empty($item)) {
$arr_standard[] = $item;
}
endwhile;
endif;
$flag = false;
foreach ($arr_size as $obj) {
$arr_size1 [] = $obj->name;
}
if (!is_null($arr_size1)) {
$arr_size1 = array_unique($arr_size1);
$attributes_filter = "<details><summary>سایز</summary>";
foreach ($arr_size1 as $size) {
if (!is_null($size))
$attributes_filter .= '<input type="checkbox" class="chkfilter" value="' . $size . '"/> <label for="size-' . $size . '">' . $size . '</label>';
}
$attributes_filter .= '</details>';
}
foreach ($arr_zekhamat as $obj) {
$arr_zekhamat1 [] = $obj->name;
}
if (!is_null($arr_zekhamat1)) {
$arr_zekhamat1 = array_unique($arr_zekhamat1);
$attributes_filter .= "<details><summary>ضخامت</summary>";
foreach ($arr_zekhamat1 as $zekhamat) {
if (!is_null($zekhamat))
$attributes_filter .= '<input type="checkbox" class="chkzekhamat" value="' . $zekhamat . '"/> <label for="zekhamat-' . $zekhamat . '">' . $zekhamat . '</label>';
}
$attributes_filter .= '</details>';
}
foreach ($arr_sizemaftol as $obj) {
$arr_sizemaftol1 [] = $obj->name;
}
if (!is_null($arr_sizemaftol1)) {
$arr_sizemaftol1 = array_unique($arr_sizemaftol1);
$attributes_filter .= "<details><summary>سایز مفتول</summary>";
foreach ($arr_sizemaftol1 as $maftol) {
if (!is_null($maftol))
$attributes_filter .= '<input type="checkbox" class="chkmaftol" value="' . $maftol . '"/> <label for="maftol-' . $maftol . '">' . $maftol . '</label>';
}
$attributes_filter .= '</details>';
}
foreach ($arr_scale as $obj) {
$arr_scale1 [] = $obj->name;
}
if (!is_null($arr_scale1)) {
$arr_scale1 = array_unique($arr_scale1);
$attributes_filter .= "<details><summary>ابعاد</summary>";
foreach ($arr_scale1 as $scale) {
if (!is_null($scale))
$attributes_filter .= '<input type="checkbox" class="chkscale" value="' . $scale . '"/> <label for="scale-' . $scale . '">' . $scale . '</label>';
}
$attributes_filter .= '</details>';
}
foreach ($arr_standard as $obj) {
$arr_standard1 [] = $obj->name;
}
if (!is_null($arr_standard1)) {
$arr_standard1 = array_unique($arr_standard1);
$attributes_filter .= "<details><summary>استاندارد</summary>";
foreach ($arr_standard1 as $standard) {
if (!is_null($standard))
$attributes_filter .= '<input type="checkbox" class="chkstandard" value="' . $standard . '"/> <label for="standard-' . $standard . '">' . $standard . '</label>';
}
$attributes_filter .= '</details>';
}
$thumbnail_id = get_woocommerce_term_meta($category->term_id, 'thumbnail_id', true);
$image = wp_get_attachment_url($thumbnail_id);
?>
<div class="container pt-5 pb-5">
<div class="row ltr">
<div class="col-sm-9">
<div class="row mr-0 ml-0 border-gray ltr" id="introduce">
<div class="col-md-3 pt-2 fakeimg">
<?php if ($image): ?>
<img class="img-fluid border-gray" src="<?php echo $image; ?>" alt="">
<?php endif; ?>
</div>
<div class="col-md-9">
<p id="cate_name" class="h5 font-weight-bold yelow"><?php echo $category_name ?></p>
<p class="jojo">
<?php echo get_term_meta($category->term_id, 'des_top', true); ?>
</p>
<button type="button" id="jojobtn" class="btn bg-yelow text-white">
نمایش بیشتر
</button>
</div>
</div>
</div>
<div class="col-sm-3">
<div class="slidbar" id="filter">
<div class="header-slider bg-yelow text-white p-2">
<i class="fas fa-filter h6"></i> فیلتر ها
</div>
<ul>
<?php echo $attributes_filter; ?>
</ul>
</div>
</div>
<div class="container">
<div class="col-sm-12">
<div class=" p-3 mt-3" id="table">
</div>
</div>
</div>
</div>
</div>
<script>
jQuery('#jojobtn').click(function () {
jQuery('.jojo').toggleClass('active')
});
</script>
<?php get_footer(); ?>