PluginProbe ʕ •ᴥ•ʔ
ShopEngine Elementor WooCommerce Builder Addon – All in One WooCommerce Solution with eCommerce Templates & Woo Widgets / 4.9.5
ShopEngine Elementor WooCommerce Builder Addon – All in One WooCommerce Solution with eCommerce Templates & Woo Widgets v4.9.5
4.9.5 4.9.4 4.9.3 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 1 week ago
default.php
323 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 <?php if (!isset($show_product_hover_overlay) || $show_product_hover_overlay === 'yes') : ?>
192 <div class="overlay-add-to-cart position-<?php echo isset($product_hover_overlay_position) ? esc_attr($product_hover_overlay_position) : 'bottom'; ?>">
193 <?php woocommerce_template_loop_add_to_cart();?>
194 </div>
195 <?php endif; ?>
196 <!-- tag and sale badge -->
197 <?php
198 $product_tags = get_the_terms(get_the_ID(), 'product_tag');
199 $badge_position = !empty($badge_position) ? $badge_position : 'top-right';
200 $badge_align = !empty($badge_align) ? $badge_align : 'horizontal';
201 ?>
202 <div class="product-tag-sale-badge position-<?php echo esc_attr($badge_position); ?> align-<?php echo esc_attr($badge_align); ?>">
203 <ul>
204 <!-- percentage -->
205 <?php
206 if($show_off === "yes"){
207 if (!empty($product->get_regular_price()) && !empty($product->get_sale_price()) && $product->get_regular_price() !== $product->get_sale_price() ): ?>
208 <li class="badge no-link off">
209 <?php
210 $percentage = round((($product->get_regular_price() - $product->get_sale_price()) / $product->get_regular_price()) * 100);
211 echo esc_html(sprintf('%1$s%2$s%3$s', '-', $percentage, '%'));
212 ?>
213 </li>
214 <?php endif;} ?>
215 <!-- custom tags -->
216 <?php
217 if($show_tag === "yes"){
218 if($product_tags && !is_wp_error($product_tags)):
219 $product_tag = $product_tags[0];
220 $bg = get_term_meta($product_tag->term_id, 'devmonsta_bajaar_tag_bg_color', true); ?>
221 <li class="badge tag">
222 <a title="<?php echo esc_html($product_tag->name, 'shopengine');?>" href="<?php echo esc_url(get_term_link($product_tag->term_id)); ?>">
223 <?php esc_html_e($product_tag->name, 'shopengine'); ?></a>
224 </li>
225 <?php endif;} ?>
226 <!-- on sale -->
227 <?php
228 if($show_sale === "yes"){
229 if ($product->is_on_sale()) :?>
230 <li class='badge no-link sale'><?php esc_html_e('Sale!', 'shopengine')?></li>
231 <?php endif;} ?>
232 <!-- out of stock -->
233 <?php
234 if($show_stock_out_badge === "yes"){
235 if(!$product->is_in_stock()):?>
236 <li class="badge no-link out-of-stock">
237 <?php echo esc_html__('Out of Stock', 'shopengine'); ?>
238 </li>
239 <?php endif;} ?>
240 </ul>
241 </div>
242 </div>
243
244 <!-- product category -->
245 <?php if($product_view_style === "list"): ?>
246 <div class="list-view-wrapper-contents">
247 <?php endif; ?>
248 <?php
249 $product_cats = get_the_terms(get_the_ID(), 'product_cat');
250 $category_limit = (isset($category_limit) && !empty($category_limit)) ? esc_attr($category_limit) : 1;
251
252 if ($product_cats && !is_wp_error($product_cats)):
253 $slice_product_cats = array_slice($product_cats, 0, $category_limit);
254 if (count($slice_product_cats) > 0): ?>
255 <div class='product-category'>
256 <ul>
257 <?php foreach ($slice_product_cats as $key => $product_cat): ?>
258 <li>
259 <a title="<?php esc_html_e('Product Category','shopengine')?>" href="<?php echo esc_url(get_term_link($product_cat)); ?>">
260 <?php
261 echo esc_html($product_cat->name);
262 if ($key !== (count($slice_product_cats) - 1)) {
263 echo ',';
264 }
265 ?>
266 </a>
267 </li>
268 <?php endforeach;?>
269 </ul>
270 </div>
271 <?php endif;
272 endif;
273 ?>
274
275 <!-- product title -->
276 <h3 class='product-title'>
277 <a title="<?php esc_html_e('View Product Full Details','shopengine')?>" href="<?php the_permalink();?>">
278 <?php
279 if (isset($title_character) && !empty($title_character)):
280 echo esc_html(substr(get_the_title(), 0, $title_character));
281 else:
282 echo esc_html(get_the_title());
283 endif;
284 ?>
285 </a>
286 </h3>
287
288 <!-- product rating -->
289 <div class="product-rating">
290 <?php
291 if ($product->get_rating_count() > 0) {
292 woocommerce_template_loop_rating();
293 } else {
294 shopengine_content_render(sprintf('<div class="star-rating">%1$s</div>', wc_get_star_rating_html(0, 0)));
295 }
296
297 echo wp_kses(sprintf('<span class="rating-count">(%1$s)</span>', $product->get_review_count()), Helper::get_kses_array());
298 ?>
299 </div>
300
301 <!-- product price -->
302 <div class="product-price">
303 <?php woocommerce_template_single_price(); ?>
304 </div>
305 <?php if($product_view_style === "list"): ?>
306 </div>
307 <?php endif; ?>
308 </div> <!-- end item -->
309
310 <?php endwhile;?>
311
312 </div>
313
314 <?php else:
315
316 esc_html_e('No product found.', 'shopengine');
317
318 endif;
319
320 wp_reset_postdata();?>
321
322 </div>
323