Advanced Woo Search - Version 1.04

Version Description

  • Fix issue with SKU search
  • Add option to display product SKU in search results
Download this release

Release Info

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

Code changes from version 1.03 to 1.04

advanced-woo-search.php CHANGED
@@ -3,7 +3,7 @@
3
  /*
4
  Plugin Name: Advanced Woo Search
5
  Description: Advance ajax WooCommerce product search.
6
- Version: 1.03
7
  Author: ILLID
8
  Text Domain: aws
9
  */
@@ -257,7 +257,7 @@ final class AWS_Main {
257
  break;
258
 
259
  case 'sku':
260
- $search_in_array[] = $wpdb->prepare( '( postmeta.meta_value LIKE %s )', $like );
261
  break;
262
 
263
  }
@@ -290,8 +290,6 @@ final class AWS_Main {
290
  WHERE
291
  posts.post_type = 'product'
292
  AND posts.post_status = 'publish'
293
- AND posts.ID = postmeta.post_id
294
- AND postmeta.meta_key = '_sku'
295
  {$query['search']}
296
  ORDER BY
297
  relevance DESC,
@@ -339,6 +337,7 @@ final class AWS_Main {
339
  $show_price = $this->get_settings( 'show_price' );
340
  $show_sale = $this->get_settings( 'show_sale' );
341
  $show_image = $this->get_settings( 'show_image' );
 
342
 
343
  foreach ( $posts_ids as $post_id ) {
344
 
@@ -352,6 +351,7 @@ final class AWS_Main {
352
  $price = '';
353
  $on_sale = '';
354
  $image = '';
 
355
 
356
  if ( $show_excerpt === 'true' ) {
357
  $excerpt = ( $excerpt_source === 'excerpt' && $post_data->post_excerpt ) ? $post_data->post_excerpt : $post_data->post_content;
@@ -381,6 +381,10 @@ final class AWS_Main {
381
  $image = $image_attributes[0];
382
  }
383
 
 
 
 
 
384
  $categories = $product->get_categories( ',' );
385
 
386
  $tags = $product->get_tags( ',' );
@@ -393,7 +397,8 @@ final class AWS_Main {
393
  'price' => $price,
394
  'categories' => $categories,
395
  'tags' => $tags,
396
- 'on_sale' => $on_sale
 
397
  );
398
 
399
  $products_array[] = $new_result;
3
  /*
4
  Plugin Name: Advanced Woo Search
5
  Description: Advance ajax WooCommerce product search.
6
+ Version: 1.04
7
  Author: ILLID
8
  Text Domain: aws
9
  */
257
  break;
258
 
259
  case 'sku':
260
+ $search_in_array[] = $wpdb->prepare( "( posts.ID = postmeta.post_id AND postmeta.meta_key = '_sku' AND postmeta.meta_value LIKE %s )", $like );
261
  break;
262
 
263
  }
290
  WHERE
291
  posts.post_type = 'product'
292
  AND posts.post_status = 'publish'
 
 
293
  {$query['search']}
294
  ORDER BY
295
  relevance DESC,
337
  $show_price = $this->get_settings( 'show_price' );
338
  $show_sale = $this->get_settings( 'show_sale' );
339
  $show_image = $this->get_settings( 'show_image' );
340
+ $show_sku = $this->get_settings( 'show_sku' );
341
 
342
  foreach ( $posts_ids as $post_id ) {
343
 
351
  $price = '';
352
  $on_sale = '';
353
  $image = '';
354
+ $sku = '';
355
 
356
  if ( $show_excerpt === 'true' ) {
357
  $excerpt = ( $excerpt_source === 'excerpt' && $post_data->post_excerpt ) ? $post_data->post_excerpt : $post_data->post_content;
381
  $image = $image_attributes[0];
382
  }
383
 
384
+ if ( $show_sku === 'true' ) {
385
+ $sku = $product->get_sku();
386
+ }
387
+
388
  $categories = $product->get_categories( ',' );
389
 
390
  $tags = $product->get_tags( ',' );
397
  'price' => $price,
398
  'categories' => $categories,
399
  'tags' => $tags,
400
+ 'on_sale' => $on_sale,
401
+ 'sku' => $sku
402
  );
403
 
404
  $products_array[] = $new_result;
assets/css/common.css CHANGED
@@ -31,6 +31,7 @@
31
  }
32
 
33
  .aws-container .aws-search-field {
 
34
  color: #313131;
35
  padding: 6px;
36
  line-height: 30px;
@@ -107,6 +108,14 @@
107
  color: #21759b;
108
  }
109
 
 
 
 
 
 
 
 
 
110
  .aws-search-result .aws_result_cat .aws_result_title,
111
  .aws-search-result .aws_result_tag .aws_result_title {
112
  margin-bottom: 2px;
31
  }
32
 
33
  .aws-container .aws-search-field {
34
+ width: 100%;
35
  color: #313131;
36
  padding: 6px;
37
  line-height: 30px;
108
  color: #21759b;
109
  }
110
 
111
+ .aws-search-result .aws_result_sku {
112
+ display: block;
113
+ font-weight: normal;
114
+ margin-top: 3px;
115
+ margin-bottom: 5px;
116
+ color: #222;
117
+ }
118
+
119
  .aws-search-result .aws_result_cat .aws_result_title,
120
  .aws-search-result .aws_result_tag .aws_result_title {
121
  margin-bottom: 2px;
assets/js/common.js CHANGED
@@ -163,6 +163,10 @@
163
  html += '<span class="aws_result_content">';
164
  html += '<span class="aws_result_title">' + result.title + '</span>';
165
 
 
 
 
 
166
  if ( result.excerpt ) {
167
  html += '<span class="aws_result_excerpt">' + result.excerpt + '</span>';
168
  }
163
  html += '<span class="aws_result_content">';
164
  html += '<span class="aws_result_title">' + result.title + '</span>';
165
 
166
+ if ( result.sku ) {
167
+ html += '<span class="aws_result_sku">SKU: ' + result.sku + '</span>';
168
+ }
169
+
170
  if ( result.excerpt ) {
171
  html += '<span class="aws_result_excerpt">' + result.excerpt + '</span>';
172
  }
includes/options.php CHANGED
@@ -137,6 +137,18 @@ $options['general'][] = array(
137
  )
138
  );
139
 
 
 
 
 
 
 
 
 
 
 
 
 
140
  // Query tab
141
 
142
  $options['general'][] = array(
137
  )
138
  );
139
 
140
+ $options['general'][] = array(
141
+ "name" => __( "Show product SKU", "aws" ),
142
+ "desc" => __( "Show product SKU in search results.", "aws" ),
143
+ "id" => "show_sku",
144
+ "value" => 'false',
145
+ "type" => "radio",
146
+ 'choices' => array(
147
+ 'true' => 'On',
148
+ 'false' => 'Off'
149
+ )
150
+ );
151
+
152
  // Query tab
153
 
154
  $options['general'][] = array(
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: Mihail Barinov
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=GSE37FC4Y7CEY
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: 4.4.2
7
- Stable tag: 1.03
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -53,6 +53,10 @@ Or insert this function inside php file ( often it used to insert form inside pa
53
 
54
  == Changelog ==
55
 
 
 
 
 
56
  = 1.03 =
57
  * Add search in product terms ( categories, tags )
58
  * Fix issue with not saving settings
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=GSE37FC4Y7CEY
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: 4.5
7
+ Stable tag: 1.04
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
53
 
54
  == Changelog ==
55
 
56
+ = 1.04 =
57
+ * Fix issue with SKU search
58
+ * Add option to display product SKU in search results
59
+
60
  = 1.03 =
61
  * Add search in product terms ( categories, tags )
62
  * Fix issue with not saving settings