Advanced Woo Search - Version 2.38

Version Description

( 2021-10-25 ) = * Add - Support for WooCommerce Product Filter by WooBeWoo plugin * Add - Quantity change buttons for products search results. Visible on mobile devices * Update - Tested with WC 5.8 * Fix - WOOCS - WooCommerce Currency Switcher plugin support for AJAX pricing update<

Download this release

Release Info

Developer Mihail Barinov
Plugin Icon 128x128 Advanced Woo Search
Version 2.38
Comparing to
See all releases

Code changes from version 2.37 to 2.38

advanced-woo-search.php CHANGED
@@ -3,12 +3,12 @@
3
  /*
4
  Plugin Name: Advanced Woo Search
5
  Description: Advance ajax WooCommerce product search.
6
- Version: 2.37
7
  Author: ILLID
8
  Author URI: https://advanced-woo-search.com/
9
  Text Domain: advanced-woo-search
10
  WC requires at least: 3.0.0
11
- WC tested up to: 5.7.0
12
  */
13
 
14
 
@@ -96,7 +96,7 @@ final class AWS_Main {
96
  */
97
  private function define_constants() {
98
 
99
- $this->define( 'AWS_VERSION', '2.37' );
100
 
101
  $this->define( 'AWS_DIR', plugin_dir_path( AWS_FILE ) );
102
  $this->define( 'AWS_URL', plugin_dir_url( AWS_FILE ) );
3
  /*
4
  Plugin Name: Advanced Woo Search
5
  Description: Advance ajax WooCommerce product search.
6
+ Version: 2.38
7
  Author: ILLID
8
  Author URI: https://advanced-woo-search.com/
9
  Text Domain: advanced-woo-search
10
  WC requires at least: 3.0.0
11
+ WC tested up to: 5.8.0
12
  */
13
 
14
 
96
  */
97
  private function define_constants() {
98
 
99
+ $this->define( 'AWS_VERSION', '2.38' );
100
 
101
  $this->define( 'AWS_DIR', plugin_dir_path( AWS_FILE ) );
102
  $this->define( 'AWS_URL', plugin_dir_url( AWS_FILE ) );
includes/class-aws-integrations.php CHANGED
@@ -251,13 +251,6 @@ if ( ! class_exists( 'AWS_Integrations' ) ) :
251
  add_filter( 'aws_search_results_products', array( $this, 'pvbur_aws_search_results_products' ), 1 );
252
  }
253
 
254
- // WooCommerce Product Filter by WooBeWoo
255
- if ( defined( 'WPF_PLUG_NAME' ) ) {
256
- add_filter( 'wpf_addHtmlBeforeFilter', array( $this, 'wpf_add_html_before_filter' ) );
257
- add_filter( 'aws_search_page_custom_data', array( $this, 'wpf_search_page_custom_data' ) );
258
- add_filter( 'aws_search_page_filters', array( $this, 'wpf_search_page_filters' ) );
259
- }
260
-
261
  // ATUM Inventory Management for WooCommerce plugin ( Product level addon )
262
  if ( class_exists( 'AtumProductLevelsAddon' ) ) {
263
  add_filter( 'aws_indexed_data', array( $this, 'atum_index_data' ), 10, 2 );
@@ -278,8 +271,13 @@ if ( ! class_exists( 'AWS_Integrations' ) ) :
278
  add_action( 'wp_footer', array( $this, 'dce_scripts' ) );
279
  }
280
 
281
- }
 
 
 
282
 
 
 
283
  /**
284
  * Include files
285
  */
@@ -351,6 +349,11 @@ if ( ! class_exists( 'AWS_Integrations' ) ) :
351
  include_once( AWS_DIR . '/includes/modules/class-aws-wpml.php' );
352
  }
353
 
 
 
 
 
 
354
  }
355
 
356
  /*
@@ -1900,110 +1903,6 @@ if ( ! class_exists( 'AWS_Integrations' ) ) :
1900
 
1901
  }
1902
 
1903
- /*
1904
- * WooCommerce Product Filter by WooBeWoo: check for active widget
1905
- */
1906
- public function wpf_add_html_before_filter( $html ) {
1907
- $this->data['wpf_filter'] = true;
1908
- if ( isset( $_GET['type_aws'] ) ) {
1909
- $html = str_replace( '&quot;enable_ajax&quot;:&quot;1&quot;', '&quot;enable_ajax&quot;:&quot;0&quot;', $html );
1910
- $html = str_replace( '"enable_ajax":"1"', '"enable_ajax":"0"', $html );
1911
- }
1912
- return $html;
1913
- }
1914
-
1915
- /*
1916
- * WooCommerce Product Filter by WooBeWoo: fix filters display
1917
- */
1918
- public function wpf_search_page_custom_data( $data ) {
1919
- if ( isset( $this->data['wpf_filter'] ) ) {
1920
- $data['force_ids'] = true;
1921
- }
1922
- return $data;
1923
- }
1924
-
1925
- /*
1926
- * WooCommerce Product Filter by WooBeWoo: filter products
1927
- */
1928
- public function wpf_search_page_filters( $filters ) {
1929
-
1930
- foreach ( $_GET as $key => $param ) {
1931
-
1932
- $isNot = ( substr($param, 0, 1) === '!' );
1933
-
1934
- if ( strpos($key, 'filter_cat') !== false ) {
1935
-
1936
- $idsAnd = explode(',', $param);
1937
- $idsOr = explode('|', $param);
1938
- $isAnd = count($idsAnd) > count($idsOr);
1939
- $operator = $isAnd ? 'AND' : 'OR';
1940
- $filters['tax']['product_cat'] = array(
1941
- 'terms' => $isAnd ? $idsAnd : $idsOr,
1942
- 'operator' => $operator
1943
- );
1944
-
1945
- }
1946
- elseif ( strpos($key, 'product_tag') !== false ) {
1947
-
1948
- $idsAnd = explode(',', $param);
1949
- $idsOr = explode('|', $param);
1950
- $isAnd = count($idsAnd) > count($idsOr);
1951
- $operator = $isAnd ? 'AND' : 'OR';
1952
- $filters['tax']['product_tag'] = array(
1953
- 'terms' => $isAnd ? $idsAnd : $idsOr,
1954
- 'operator' => $operator
1955
- );
1956
-
1957
- }
1958
- elseif ( strpos( $key, 'pr_onsale' ) !== false ) {
1959
- $filters['on_sale'] = true;
1960
- }
1961
- elseif ( strpos( $key, 'filter_' ) === 0 ) {
1962
-
1963
- $taxonomy = str_replace( 'filter_', '', $key );
1964
- if ( preg_match( '/([a-z]+?)_[\d]/', $taxonomy, $matches ) ) {
1965
- $taxonomy = $matches[1];
1966
- }
1967
-
1968
- $idsAnd = explode(',', $param);
1969
- $idsOr = explode('|', $param);
1970
- $isAnd = count($idsAnd) > count($idsOr);
1971
- $operator = $isAnd ? 'AND' : 'OR';
1972
-
1973
- $terms_arr = $isAnd ? $idsAnd : $idsOr;
1974
-
1975
- if ( preg_match( '/[a-z]/', $param ) ) {
1976
- $new_terms_arr = array();
1977
- foreach ( $terms_arr as $term_slug ) {
1978
- $term = get_term_by('slug', $term_slug, $taxonomy );
1979
- if ( $term ) {
1980
- $new_terms_arr[] = $term->term_id;
1981
- }
1982
- if ( ! $term && strpos( $taxonomy, 'pa_' ) !== 0 ) {
1983
- $term = get_term_by('slug', $term_slug, 'pa_' . $taxonomy );
1984
- if ( $term ) {
1985
- $new_terms_arr[] = $term->term_id;
1986
- }
1987
- }
1988
- }
1989
- if ( $new_terms_arr ) {
1990
- $terms_arr = $new_terms_arr;
1991
- }
1992
- }
1993
-
1994
- $filters['tax'][$taxonomy] = array(
1995
- 'terms' => $terms_arr,
1996
- 'operator' => $operator
1997
- );
1998
-
1999
- }
2000
-
2001
- }
2002
-
2003
- return $filters;
2004
-
2005
- }
2006
-
2007
  /*
2008
  * ATUM Inventory Management for WooCommerce plugin ( Product level addon )
2009
  */
@@ -2087,6 +1986,20 @@ if ( ! class_exists( 'AWS_Integrations' ) ) :
2087
 
2088
  <?php }
2089
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2090
  }
2091
 
2092
  endif;
251
  add_filter( 'aws_search_results_products', array( $this, 'pvbur_aws_search_results_products' ), 1 );
252
  }
253
 
 
 
 
 
 
 
 
254
  // ATUM Inventory Management for WooCommerce plugin ( Product level addon )
255
  if ( class_exists( 'AtumProductLevelsAddon' ) ) {
256
  add_filter( 'aws_indexed_data', array( $this, 'atum_index_data' ), 10, 2 );
271
  add_action( 'wp_footer', array( $this, 'dce_scripts' ) );
272
  }
273
 
274
+ // WOOCS - WooCommerce Currency Switcher: fix ajax pricing loading
275
+ if ( class_exists( 'WOOCS_STARTER' ) ) {
276
+ add_filter( 'aws_search_pre_filter_products', array( $this, 'woocs_pricing_ajax_fix' ) );
277
+ }
278
 
279
+ }
280
+
281
  /**
282
  * Include files
283
  */
349
  include_once( AWS_DIR . '/includes/modules/class-aws-wpml.php' );
350
  }
351
 
352
+ // WooCommerce Product Filter by WooBeWoo
353
+ if ( defined( 'WPF_PLUG_NAME' ) ) {
354
+ include_once( AWS_DIR . '/includes/modules/class-aws-woobewoo-filters.php' );
355
+ }
356
+
357
  }
358
 
359
  /*
1903
 
1904
  }
1905
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1906
  /*
1907
  * ATUM Inventory Management for WooCommerce plugin ( Product level addon )
1908
  */
1986
 
1987
  <?php }
1988
 
1989
+ /*
1990
+ * WOOCS - WooCommerce Currency Switcher: fix ajax pricing loading
1991
+ */
1992
+ public function woocs_pricing_ajax_fix( $products_array ) {
1993
+ if ( $products_array ) {
1994
+ foreach ( $products_array as $key => $product ) {
1995
+ if ( $product['price'] && strpos( $product['price'], 'woocs_preloader_ajax' ) !== false ) {
1996
+ $products_array[$key]['price'] = str_replace( 'woocs_preloader_ajax', '', $product['price'] );
1997
+ }
1998
+ }
1999
+ }
2000
+ return $products_array;
2001
+ }
2002
+
2003
  }
2004
 
2005
  endif;
includes/modules/class-aws-woobewoo-filters.php ADDED
@@ -0,0 +1,184 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * AWS plugin WooCommerce Product Filter by WooBeWoo integration
5
+ */
6
+
7
+ if (!defined('ABSPATH')) {
8
+ exit; // Exit if accessed directly.
9
+ }
10
+
11
+ if (!class_exists('AWS_Woobewoo_Filters')) :
12
+
13
+ /**
14
+ * Class for main plugin functions
15
+ */
16
+ class AWS_Woobewoo_Filters {
17
+
18
+ /**
19
+ * @var AWS_Woobewoo_Filters The single instance of the class
20
+ */
21
+ protected static $_instance = null;
22
+
23
+ private $data = array();
24
+
25
+ /**
26
+ * Main AWS_Woobewoo_Filters Instance
27
+ *
28
+ * Ensures only one instance of AWS_Woobewoo_Filters is loaded or can be loaded.
29
+ *
30
+ * @static
31
+ * @return AWS_Woobewoo_Filters - Main instance
32
+ */
33
+ public static function instance()
34
+ {
35
+ if (is_null(self::$_instance)) {
36
+ self::$_instance = new self();
37
+ }
38
+ return self::$_instance;
39
+ }
40
+
41
+ /**
42
+ * Constructor
43
+ */
44
+ public function __construct() {
45
+
46
+ add_filter( 'wpf_addHtmlBeforeFilter', array( $this, 'wpf_add_html_before_filter' ) );
47
+
48
+ add_filter( 'aws_search_page_custom_data', array( $this, 'wpf_search_page_custom_data' ), 1 );
49
+
50
+ add_filter( 'aws_search_page_filters', array( $this, 'wpf_search_page_filters' ) );
51
+
52
+ add_filter( 'wpf_addFilterExistsItemsArgs', array( $this, 'addFilterExistsItemsArgs' ), 9999999 );
53
+
54
+ }
55
+
56
+ /*
57
+ * WooCommerce Product Filter by WooBeWoo: check for active widget
58
+ */
59
+ public function wpf_add_html_before_filter( $html ) {
60
+ $this->data['wpf_filter'] = true;
61
+ if ( isset( $_GET['type_aws'] ) ) {
62
+ $html = str_replace( '&quot;enable_ajax&quot;:&quot;1&quot;', '&quot;enable_ajax&quot;:&quot;0&quot;', $html );
63
+ $html = str_replace( '"enable_ajax":"1"', '"enable_ajax":"0"', $html );
64
+ }
65
+ return $html;
66
+ }
67
+
68
+ /*
69
+ * WooCommerce Product Filter by WooBeWoo: fix filters display
70
+ */
71
+ public function wpf_search_page_custom_data( $data ) {
72
+ $this->data['ids'] = isset( $data['ids'] ) ? $data['ids'] : array();
73
+ if ( isset( $this->data['wpf_filter'] ) ) {
74
+ $data['force_ids'] = true;
75
+ }
76
+ return $data;
77
+ }
78
+
79
+ /*
80
+ * WooCommerce Product Filter by WooBeWoo: filter products
81
+ */
82
+ public function wpf_search_page_filters( $filters ) {
83
+
84
+ foreach ( $_GET as $key => $param ) {
85
+
86
+ $isNot = ( substr($param, 0, 1) === '!' );
87
+
88
+ if ( strpos($key, 'filter_cat') !== false ) {
89
+
90
+ $idsAnd = explode(',', $param);
91
+ $idsOr = explode('|', $param);
92
+ $isAnd = count($idsAnd) > count($idsOr);
93
+ $operator = $isAnd ? 'AND' : 'OR';
94
+ $filters['tax']['product_cat'] = array(
95
+ 'terms' => $isAnd ? $idsAnd : $idsOr,
96
+ 'operator' => $operator
97
+ );
98
+
99
+ }
100
+ elseif ( strpos($key, 'product_tag') !== false ) {
101
+
102
+ $idsAnd = explode(',', $param);
103
+ $idsOr = explode('|', $param);
104
+ $isAnd = count($idsAnd) > count($idsOr);
105
+ $operator = $isAnd ? 'AND' : 'OR';
106
+ $filters['tax']['product_tag'] = array(
107
+ 'terms' => $isAnd ? $idsAnd : $idsOr,
108
+ 'operator' => $operator
109
+ );
110
+
111
+ }
112
+ elseif ( strpos( $key, 'pr_onsale' ) !== false ) {
113
+ $filters['on_sale'] = true;
114
+ }
115
+ elseif ( strpos( $key, 'filter_' ) === 0 ) {
116
+
117
+ $taxonomy = str_replace( 'filter_', '', $key );
118
+ if ( preg_match( '/([a-z]+?)_[\d]/', $taxonomy, $matches ) ) {
119
+ $taxonomy = $matches[1];
120
+ }
121
+
122
+ $idsAnd = explode(',', $param);
123
+ $idsOr = explode('|', $param);
124
+ $isAnd = count($idsAnd) > count($idsOr);
125
+ $operator = $isAnd ? 'AND' : 'OR';
126
+
127
+ $terms_arr = $isAnd ? $idsAnd : $idsOr;
128
+
129
+ if ( preg_match( '/[a-z]/', $param ) ) {
130
+ $new_terms_arr = array();
131
+ foreach ( $terms_arr as $term_slug ) {
132
+ $term = get_term_by('slug', $term_slug, $taxonomy );
133
+ if ( $term ) {
134
+ $new_terms_arr[] = $term->term_id;
135
+ }
136
+ if ( ! $term && strpos( $taxonomy, 'pa_' ) !== 0 ) {
137
+ $term = get_term_by('slug', $term_slug, 'pa_' . $taxonomy );
138
+ if ( $term ) {
139
+ $new_terms_arr[] = $term->term_id;
140
+ }
141
+ }
142
+ }
143
+ if ( $new_terms_arr ) {
144
+ $terms_arr = $new_terms_arr;
145
+ }
146
+ }
147
+
148
+ $filters['tax'][$taxonomy] = array(
149
+ 'terms' => $terms_arr,
150
+ 'operator' => $operator
151
+ );
152
+
153
+ }
154
+
155
+ }
156
+
157
+ return $filters;
158
+
159
+ }
160
+
161
+ /*
162
+ * Add posts Ids into filters arguments for WP_Query
163
+ */
164
+ public function addFilterExistsItemsArgs( $args ) {
165
+
166
+ if ( isset( $this->data['wpf_filter'] ) && isset( $this->data['ids'] ) ) {
167
+
168
+ $args['post__in'] = array_keys( $this->data['ids'] );
169
+
170
+ if ( isset( $args['s'] ) ) {
171
+ unset( $args['s'] );
172
+ }
173
+
174
+ }
175
+
176
+ return $args;
177
+
178
+ }
179
+
180
+ }
181
+
182
+ endif;
183
+
184
+ AWS_Woobewoo_Filters::instance();
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
4
  Tags: widget, plugin, woocommerce, search, product search, woocommerce search, ajax search, live search, custom search, ajax, shortcode, better search, relevance search, relevant search, search by sku, search plugin, shop, store, wordpress search, wp ajax search, wp search, wp search plugin, sidebar, ecommerce, merketing, products, category search, instant-search, search highlight, woocommerce advanced search, woocommerce live search, WooCommerce Plugin, woocommerce product search
5
  Requires at least: 4.0
6
  Tested up to: 5.8
7
- Stable tag: 2.37
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -167,6 +167,12 @@ Yep. This plugin is always compatible with the latest version of Woocommerce?
167
 
168
  == Changelog ==
169
 
 
 
 
 
 
 
170
  = 2.37 ( 2021-10-11 ) =
171
  * Add - Support for B2BKing plugin
172
  * Update - Hide out-of-stock items by default if corresponding WC option is enabled
4
  Tags: widget, plugin, woocommerce, search, product search, woocommerce search, ajax search, live search, custom search, ajax, shortcode, better search, relevance search, relevant search, search by sku, search plugin, shop, store, wordpress search, wp ajax search, wp search, wp search plugin, sidebar, ecommerce, merketing, products, category search, instant-search, search highlight, woocommerce advanced search, woocommerce live search, WooCommerce Plugin, woocommerce product search
5
  Requires at least: 4.0
6
  Tested up to: 5.8
7
+ Stable tag: 2.38
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
167
 
168
  == Changelog ==
169
 
170
+ = 2.38 ( 2021-10-25 ) =
171
+ * Add - Support for WooCommerce Product Filter by WooBeWoo plugin
172
+ * Add - Quantity change buttons for products search results. Visible on mobile devices
173
+ * Update - Tested with WC 5.8
174
+ * Fix - WOOCS - WooCommerce Currency Switcher plugin support for AJAX pricing update<
175
+
176
  = 2.37 ( 2021-10-11 ) =
177
  * Add - Support for B2BKing plugin
178
  * Update - Hide out-of-stock items by default if corresponding WC option is enabled