PluginProbe ʕ •ᴥ•ʔ
ShopEngine Elementor WooCommerce Builder Addon – All in One WooCommerce Solution / 4.9.2
ShopEngine Elementor WooCommerce Builder Addon – All in One WooCommerce Solution v4.9.2
4.9.2 4.9.1 4.9.0 2.0.0 2.1.0 2.2.0 2.2.1 2.2.2 2.3.0 2.4.0 2.5.0 2.5.1 3.0.0 3.1.0 3.1.1 4.0.0 4.0.1 4.1.0 4.1.1 4.2.0 4.2.1 4.3.0 4.3.1 4.4.0 4.5.0 4.5.1 4.6.0 4.6.1 4.6.2 4.6.3 4.6.4 4.6.5 4.6.6 4.6.7 4.6.8 4.6.9 4.7.0 4.7.1 4.7.2 4.7.3 4.7.4 4.7.5 4.7.6 4.7.7 4.7.8 4.7.9 4.8.0 4.8.1 4.8.2 4.8.3 4.8.4 4.8.5 4.8.6 4.8.7 4.8.8 4.8.9 trunk 0.1.2-beta 0.1.3-beta 0.1.4-beta 1.0.0 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.2.1 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.4.0 1.4.1 1.5.0 1.5.1 1.6.0 1.6.1 1.7.0 1.8.0 1.8.1 1.9.0
shopengine / widgets / product-list / screens / default.php
shopengine / widgets / product-list / screens Last commit date
default.php 6 days ago
default.php
321 lines
1 <?php
2
3 use ShopEngine\Utils\Helper;
4
5 defined('ABSPATH') || exit;
6 // product query
7 $args = [
8 'post_type' => 'product',
9 'posts_per_page' => isset($products_per_page) ? $products_per_page : 6,
10 'order' => isset($product_order) ? $product_order : 'DESC'
11 ];
12 if( $out_of_stock_product_visibility == 'hide'|| ( $out_of_stock_product_visibility == 'default' && 'yes' == get_option('woocommerce_hide_out_of_stock_items'))){
13 $args['meta_query'] [] = array(
14 'key' => '_stock_status',
15 'value' => 'outofstock',
16 'compare' => '!='
17 );
18 }
19 if (isset($product_orderby)) {
20 switch ($product_orderby) {
21 case 'price':
22 $args['meta_key'] = '_price';
23 $args['orderby'] = 'meta_value_num';
24 break;
25 case 'sales':
26 $args['meta_key'] = 'total_sales';
27 $args['orderby'] = 'meta_value_num';
28 break;
29 case 'rated':
30 $args['meta_key'] = '_wc_average_rating';
31 $args['orderby'] = 'meta_value_num';
32 break;
33 case 'sku':
34 $args['meta_key'] = '_sku';
35 $args['orderby'] = 'meta_value';
36 break;
37 case 'stock_status':
38 $args['meta_key'] = '_stock_status';
39 $args['orderby'] = 'meta_value';
40 break;
41 default:
42 $args['orderby'] = $product_orderby;
43 }
44 } else {
45 $args['orderby'] = 'date';
46 }
47
48 $product_visibility_term_ids = wc_get_product_visibility_term_ids();
49
50 switch ($product_by) {
51 case 'category':
52 $args['tax_query'] = [
53 [
54 'taxonomy' => 'product_cat',
55 'field' => 'term_id',
56 'terms' => (isset($term_list) && !empty($term_list)) ? $term_list : []
57 ]
58 ];
59 break;
60 case 'tag':
61 $args['tax_query'] = [
62 [
63 'taxonomy' => 'product_tag',
64 'field' => 'term_id',
65 'terms' => (isset($tag_lists) && !empty($tag_lists)) ? $tag_lists : []
66 ]
67 ];
68 break;
69 case 'rating':
70 $product_visibility_terms = wc_get_product_visibility_term_ids();
71 $product_visibility_not_in = [];
72 $rating_terms = [];
73
74 if ('yes' === get_option('woocommerce_hide_out_of_stock_items')) {
75 $product_visibility_not_in[] = $product_visibility_terms['outofstock'];
76 }
77
78 for ($i = 1; $i <= 5; $i++) {
79
80 $t_dx = 'rated-' . $i;
81
82 if (in_array($i, $rating_list, false) && isset($product_visibility_terms[$t_dx])) {
83 $rating_terms[] = $product_visibility_terms[$t_dx];
84 }
85 }
86
87 if (!empty($rating_terms)) {
88 $tax_query[] = [
89 'taxonomy' => 'product_visibility',
90 'field' => 'term_taxonomy_id',
91 'terms' => $rating_terms,
92 'operator' => 'IN',
93 'rating_filter' => true
94 ];
95 }
96
97 if (!empty($product_visibility_not_in)) {
98 $tax_query[] = [
99 'taxonomy' => 'product_visibility',
100 'field' => 'term_taxonomy_id',
101 'terms' => $product_visibility_not_in,
102 'operator' => 'NOT IN'
103 ];
104 }
105
106 if (!empty($tax_query)) {
107 $args['tax_query'] = $tax_query;
108 }
109 break;
110 case 'attribute':
111 if (!empty($pa_attribute_list)) {
112
113 $tx_qry = [
114 'relation' => 'OR'
115 ];
116
117 foreach ($pa_attribute_list as $txn) {
118
119 $terms = get_terms($txn);
120 $terms_slug = [];
121
122 foreach($terms as $term) {
123 $terms_slug[] = $term->slug;
124 }
125
126 $tx_qry[] = [
127 'taxonomy' => $txn,
128 'field' => 'slug',
129 'terms' => $terms_slug,
130 'operator' => 'IN'
131 ];
132 }
133
134 $args['tax_query'] = $tx_qry;
135 }
136 break;
137 case 'author':
138 $args['author__in'] = (isset($author_list) && !empty($author_list)) ? $author_list : [];
139 break;
140 case 'product':
141 $args['post__in'] = (isset($product_list) && !empty($product_list)) ? $product_list : [];
142 break;
143 case 'featured':
144 $args['tax_query'][] = [
145 'taxonomy' => 'product_visibility',
146 'field' => 'term_taxonomy_id',
147 'terms' => $product_visibility_term_ids['featured']
148 ];
149 break;
150 case 'sale':
151 $args['post__in'] = wc_get_product_ids_on_sale();
152 break;
153 case 'viewed':
154 $viewed_products = !empty($_COOKIE['woocommerce_recently_viewed']) ? (array) explode('|', sanitize_text_field(wp_unslash($_COOKIE['woocommerce_recently_viewed']))) : [];
155 $viewed_products = array_reverse(array_filter(array_map('absint', $viewed_products)));
156 $query_args['post__in'] = $viewed_products;
157 break;
158 }
159
160 $productQuery = new \WP_Query($args);
161
162 // Remove Woostify theme conflicts for ShopEngine widgets
163 $themeName = get_template();
164 if ($themeName === 'woostify') {
165 // Remove the conflicting filter hook
166 remove_filter('woocommerce_loop_add_to_cart_link', 'woostify_modify_woocommerce_loop_add_to_cart_link', 99, 3);
167 }
168
169 ?>
170
171 <div class="shopengine-product-list">
172
173 <?php if ($productQuery->have_posts()): ?>
174
175 <div class="<?php echo $product_view_style === "list" ? esc_attr("product-list-view") : esc_attr("product-list-grid"); ?>">
176
177 <?php while ($productQuery->have_posts()): $productQuery->the_post();
178 $product = wc_get_product(get_the_ID());?>
179
180 <div class="shopengine-single-product-item">
181
182 <!-- product thumb -->
183 <div class="product-thumb">
184
185 <!-- product thumb -->
186 <a title="<?php esc_attr_e('View Product Full Details','shopengine')?>" href="<?php echo esc_url(get_the_permalink()); ?>">
187 <?php shopengine_content_render(woocommerce_get_product_thumbnail($product->get_id())); ?>
188 </a>
189
190 <!-- add to cart -->
191 <div class="overlay-add-to-cart position-<?php echo isset($product_hover_overlay_position) ? esc_attr($product_hover_overlay_position) : 'bottom'; ?>">
192 <?php woocommerce_template_loop_add_to_cart();?>
193 </div>
194 <!-- tag and sale badge -->
195 <?php
196 $product_tags = get_the_terms(get_the_ID(), 'product_tag');
197 $badge_position = !empty($badge_position) ? $badge_position : 'top-right';
198 $badge_align = !empty($badge_align) ? $badge_align : 'horizontal';
199 ?>
200 <div class="product-tag-sale-badge position-<?php echo esc_attr($badge_position); ?> align-<?php echo esc_attr($badge_align); ?>">
201 <ul>
202 <!-- percentage -->
203 <?php
204 if($show_off === "yes"){
205 if (!empty($product->get_regular_price()) && !empty($product->get_sale_price()) && $product->get_regular_price() !== $product->get_sale_price() ): ?>
206 <li class="badge no-link off">
207 <?php
208 $percentage = round((($product->get_regular_price() - $product->get_sale_price()) / $product->get_regular_price()) * 100);
209 echo esc_html(sprintf('%1$s%2$s%3$s', '-', $percentage, '%'));
210 ?>
211 </li>
212 <?php endif;} ?>
213 <!-- custom tags -->
214 <?php
215 if($show_tag === "yes"){
216 if($product_tags && !is_wp_error($product_tags)):
217 $product_tag = $product_tags[0];
218 $bg = get_term_meta($product_tag->term_id, 'devmonsta_bajaar_tag_bg_color', true); ?>
219 <li class="badge tag">
220 <a title="<?php echo esc_html($product_tag->name, 'shopengine');?>" href="<?php echo esc_url(get_term_link($product_tag->term_id)); ?>">
221 <?php esc_html_e($product_tag->name, 'shopengine'); ?></a>
222 </li>
223 <?php endif;} ?>
224 <!-- on sale -->
225 <?php
226 if($show_sale === "yes"){
227 if ($product->is_on_sale()) :?>
228 <li class='badge no-link sale'><?php esc_html_e('Sale!', 'shopengine')?></li>
229 <?php endif;} ?>
230 <!-- out of stock -->
231 <?php
232 if($show_stock_out_badge === "yes"){
233 if(!$product->is_in_stock()):?>
234 <li class="badge no-link out-of-stock">
235 <?php echo esc_html__('Out of Stock', 'shopengine'); ?>
236 </li>
237 <?php endif;} ?>
238 </ul>
239 </div>
240 </div>
241
242 <!-- product category -->
243 <?php if($product_view_style === "list"): ?>
244 <div class="list-view-wrapper-contents">
245 <?php endif; ?>
246 <?php
247 $product_cats = get_the_terms(get_the_ID(), 'product_cat');
248 $category_limit = (isset($category_limit) && !empty($category_limit)) ? esc_attr($category_limit) : 1;
249
250 if ($product_cats && !is_wp_error($product_cats)):
251 $slice_product_cats = array_slice($product_cats, 0, $category_limit);
252 if (count($slice_product_cats) > 0): ?>
253 <div class='product-category'>
254 <ul>
255 <?php foreach ($slice_product_cats as $key => $product_cat): ?>
256 <li>
257 <a title="<?php esc_html_e('Product Category','shopengine')?>" href="<?php echo esc_url(get_term_link($product_cat)); ?>">
258 <?php
259 echo esc_html($product_cat->name);
260 if ($key !== (count($slice_product_cats) - 1)) {
261 echo ',';
262 }
263 ?>
264 </a>
265 </li>
266 <?php endforeach;?>
267 </ul>
268 </div>
269 <?php endif;
270 endif;
271 ?>
272
273 <!-- product title -->
274 <h3 class='product-title'>
275 <a title="<?php esc_html_e('View Product Full Details','shopengine')?>" href="<?php the_permalink();?>">
276 <?php
277 if (isset($title_character) && !empty($title_character)):
278 echo esc_html(substr(get_the_title(), 0, $title_character));
279 else:
280 echo esc_html(get_the_title());
281 endif;
282 ?>
283 </a>
284 </h3>
285
286 <!-- product rating -->
287 <div class="product-rating">
288 <?php
289 if ($product->get_rating_count() > 0) {
290 woocommerce_template_loop_rating();
291 } else {
292 shopengine_content_render(sprintf('<div class="star-rating">%1$s</div>', wc_get_star_rating_html(0, 0)));
293 }
294
295 echo wp_kses(sprintf('<span class="rating-count">(%1$s)</span>', $product->get_review_count()), Helper::get_kses_array());
296 ?>
297 </div>
298
299 <!-- product price -->
300 <div class="product-price">
301 <?php woocommerce_template_single_price(); ?>
302 </div>
303 <?php if($product_view_style === "list"): ?>
304 </div>
305 <?php endif; ?>
306 </div> <!-- end item -->
307
308 <?php endwhile;?>
309
310 </div>
311
312 <?php else:
313
314 esc_html_e('No product found.', 'shopengine');
315
316 endif;
317
318 wp_reset_postdata();?>
319
320 </div>
321