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 / recently-viewed-products / screens / default.php
shopengine / widgets / recently-viewed-products / screens Last commit date
default.php 1 year ago
default.php
141 lines
1 <?php defined('ABSPATH') || exit; ?>
2 <div class="shopengine-recently-viewed-products">
3
4 <?php if(!empty($_COOKIE['shopengine_recent_viewed_product']) && isset($settings['shopengine_recently_viewed_product_show_products_heading']) && $settings['shopengine_recently_viewed_product_show_products_heading'] == 'yes' ){ ?>
5 <h2 class="shopengine-recently-viewed-products-heading-title"><?php echo esc_html( $settings['shopengine_recently_viewed_product_show_products_heading_title'] ?? ''); ?></h2>
6 <?php }?>
7
8 <div class="recent-viewed-product-list">
9 <?php
10 $args = [
11 'post_type' => 'product',
12 'orderby' => 'post__in'
13 ];
14 $no_cookie_posts = false;
15
16 if (!empty($_COOKIE['shopengine_recent_viewed_product'])) {
17
18 $product_ids = array_unique(explode(',', sanitize_text_field(wp_unslash($_COOKIE['shopengine_recent_viewed_product']))));
19
20 // It is removing the current product id from the product ids
21 // If it is the single product template then only need to check it
22 if ( is_single() && 'product' == get_post_type() ) {
23
24 $product_id = $product->get_id();
25
26 $cookie_array_key = array_search($product_id, $product_ids);
27 if (false !== $cookie_array_key) {
28 unset($product_ids[$cookie_array_key]);
29 }
30 }
31
32 $product_limit = !empty($settings['products_per_page']) ? intval($settings['products_per_page']) : 6;
33
34 if (isset($settings['product_order']) && $settings['product_order'] == 'ASC') {
35
36 $product_ids = array_reverse($product_ids);
37
38 if($product_limit < count($product_ids)) {
39 $product_ids = array_slice($product_ids, 0, $product_limit);
40 }
41
42 } else {
43
44 $total_product = count($product_ids);
45
46 if($product_limit < $total_product) {
47 $product_ids = array_slice($product_ids, $total_product - $product_limit, $total_product - 1);
48 }
49 }
50 $args['post__in'] = isset($product_ids) ? $product_ids : [];
51
52 } else {
53
54 $editor_mode = (\Elementor\Plugin::$instance->editor->is_edit_mode() || is_preview());
55
56 if( $settings['out_of_stock_product_visibility'] == 'hide' || ( $settings['out_of_stock_product_visibility'] == 'default' && 'yes' == get_option('woocommerce_hide_out_of_stock_items'))){
57 $args['meta_query'] [] = array(
58 'key' => '_stock_status',
59 'value' => 'outofstock',
60 'compare' => '!='
61 );
62 }
63
64
65 if($editor_mode){
66 $product_limit = isset($settings['products_per_page']) ? $settings['products_per_page'] : 4;
67 $order = isset($settings['product_order']) ? $settings['product_order'] : 'ASC';
68
69
70 $products = get_posts(
71 array(
72 'post_type' => 'product',
73 'posts_per_page' => $product_limit,
74 'order' => $order,
75
76 ),
77
78 );
79
80 if ($products) {
81 $product_ids = wp_list_pluck($products, 'ID');
82 }
83
84 $args['post__in'] = isset($product_ids) ? $product_ids : [];
85
86 } else {
87 $no_cookie_posts = true;
88 }
89 }
90
91 if(!$no_cookie_posts) {
92 $view = ['image','title','price','buttons'];
93 $query = new WP_Query($args);
94
95 if($query->have_posts()) :
96 while($query->have_posts()) :
97 $query->the_post();
98
99 $default_content = [
100 'image',
101 'category',
102 'title',
103 'rating',
104 'price',
105 'description',
106 'buttons'
107 ];
108
109 $content = (!empty($view) ? $view : $default_content);
110 asort($content, SORT_NUMERIC);
111 ?>
112 <div class='shopengine-single-product-item'>
113 <?php
114 foreach($content as $key => $value) {
115 $function = '_product_' . (is_numeric($value) ? $key : $value);
116 \ShopEngine\Utils\Helper::$function($settings);
117 }
118
119 if(!empty($settings['counter_position']) && $settings['counter_position'] == 'footer') {
120 \ShopEngine\Utils\Helper::_product_sale_end_date($settings, esc_html__('Ends in ', 'shopengine'));
121 }
122 ?>
123
124 </div>
125 <?php
126 endwhile;
127 endif;
128 wp_reset_query();
129 wp_reset_postdata();
130 } else {
131
132 if( isset($settings['shopengine_recently_viewed_product_hide_if_products_not_found']) && $settings['shopengine_recently_viewed_product_hide_if_products_not_found'] == 'yes' ) {
133 return;
134 }
135 echo esc_html_e("No recently viewed products to display", "shopengine");
136 }
137
138 ?>
139 </div>
140 </div>
141