Version Description
( 2021-04-27 ) = * Update - Tested with WC 5.2 * Update - Wholesale Pricing plugin support * Update - BeRocket WooCommerce AJAX Products Filter support. Fix bug with slugs in URL for attributes filters * Update - Disable automatic re-index after WP All Import plugin finish importing * Update - Notice for plugin settings page * Update - Search form markup for label tag * Fix - Ajax request issue with sending parameters * Fix - CoCart plugin issue with empty cart when performing AJAX search * Fix - Bug with the empty search results page
Download this release
Release Info
Developer | Mihail Barinov |
Plugin | Advanced Woo Search |
Version | 2.26 |
Comparing to | |
See all releases |
Code changes from version 2.25 to 2.26
- advanced-woo-search.php +3 -3
- assets/css/admin.css +8 -2
- includes/admin/class-aws-admin-meta-boxes.php +1 -1
- includes/class-aws-integrations.php +12 -69
- includes/class-aws-markup.php +1 -1
- includes/class-aws-search-page.php +96 -69
- includes/modules/class-aws-wholesale.php +226 -0
- languages/advanced-woo-search.pot +3 -0
- readme.txt +12 -1
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.
|
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.
|
12 |
*/
|
13 |
|
14 |
|
@@ -96,7 +96,7 @@ final class AWS_Main {
|
|
96 |
*/
|
97 |
private function define_constants() {
|
98 |
|
99 |
-
$this->define( 'AWS_VERSION', '2.
|
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.26
|
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.2.0
|
12 |
*/
|
13 |
|
14 |
|
96 |
*/
|
97 |
private function define_constants() {
|
98 |
|
99 |
+
$this->define( 'AWS_VERSION', '2.26' );
|
100 |
|
101 |
$this->define( 'AWS_DIR', plugin_dir_path( AWS_FILE ) );
|
102 |
$this->define( 'AWS_URL', plugin_dir_url( AWS_FILE ) );
|
assets/css/admin.css
CHANGED
@@ -80,7 +80,8 @@
|
|
80 |
margin-top: 4px;
|
81 |
}
|
82 |
|
83 |
-
#aws-reindex .reindex-progress
|
|
|
84 |
display: none;
|
85 |
margin-left: 15px;
|
86 |
position: relative;
|
@@ -89,8 +90,13 @@
|
|
89 |
font-weight: bold;
|
90 |
}
|
91 |
|
|
|
|
|
|
|
|
|
92 |
#aws-reindex.loading .loader,
|
93 |
-
#aws-reindex.loading .reindex-progress
|
|
|
94 |
display: inline-block;
|
95 |
}
|
96 |
|
80 |
margin-top: 4px;
|
81 |
}
|
82 |
|
83 |
+
#aws-reindex .reindex-progress,
|
84 |
+
#aws-reindex .reindex-notice {
|
85 |
display: none;
|
86 |
margin-left: 15px;
|
87 |
position: relative;
|
90 |
font-weight: bold;
|
91 |
}
|
92 |
|
93 |
+
#aws-reindex .reindex-notice {
|
94 |
+
font-weight: normal;
|
95 |
+
}
|
96 |
+
|
97 |
#aws-reindex.loading .loader,
|
98 |
+
#aws-reindex.loading .reindex-progress,
|
99 |
+
#aws-reindex.loading .reindex-notice {
|
100 |
display: inline-block;
|
101 |
}
|
102 |
|
includes/admin/class-aws-admin-meta-boxes.php
CHANGED
@@ -43,7 +43,7 @@ if ( ! class_exists( 'AWS_Admin_Meta_Boxes' ) ) :
|
|
43 |
|
44 |
$html .= '<th>' . esc_html__( 'Reindex table', 'advanced-woo-search' ) . '</th>';
|
45 |
$html .= '<td>';
|
46 |
-
$html .= '<div id="aws-reindex"><input class="button" type="button" value="' . esc_attr__( 'Reindex table', 'advanced-woo-search' ) . '"><span class="loader"></span><span class="reindex-progress">0%</span></div><br><br>';
|
47 |
$html .= '<span class="description">' .
|
48 |
sprintf( esc_html__( 'This action only need for %s one time %s - after you activate this plugin. After this all products changes will be re-indexed automatically.', 'advanced-woo-search' ), '<strong>', '</strong>' ) . '<br>' .
|
49 |
__( 'Update all data in plugins index table. Index table - table with products data where plugin is searching all typed terms.<br>Use this button if you think that plugin not shows last actual data in its search results.<br>' .
|
43 |
|
44 |
$html .= '<th>' . esc_html__( 'Reindex table', 'advanced-woo-search' ) . '</th>';
|
45 |
$html .= '<td>';
|
46 |
+
$html .= '<div id="aws-reindex"><input class="button" type="button" value="' . esc_attr__( 'Reindex table', 'advanced-woo-search' ) . '"><span class="loader"></span><span class="reindex-progress">0%</span><span class="reindex-notice">' . __( 'Please do not close the page.', 'advanced-woo-search' ) . '</span></div><br><br>';
|
47 |
$html .= '<span class="description">' .
|
48 |
sprintf( esc_html__( 'This action only need for %s one time %s - after you activate this plugin. After this all products changes will be re-indexed automatically.', 'advanced-woo-search' ), '<strong>', '</strong>' ) . '<br>' .
|
49 |
__( 'Update all data in plugins index table. Index table - table with products data where plugin is searching all typed terms.<br>Use this button if you think that plugin not shows last actual data in its search results.<br>' .
|
includes/class-aws-integrations.php
CHANGED
@@ -186,11 +186,6 @@ if ( ! class_exists( 'AWS_Integrations' ) ) :
|
|
186 |
|
187 |
add_action( 'wp_head', array( $this, 'head_js_integration' ) );
|
188 |
|
189 |
-
// Wholesale plugin hide certain products
|
190 |
-
if ( class_exists( 'WooCommerceWholeSalePrices' ) ) {
|
191 |
-
add_filter( 'aws_search_results_products', array( $this, 'wholesale_hide_products' ) );
|
192 |
-
}
|
193 |
-
|
194 |
// Search Exclude plugin
|
195 |
if ( class_exists( 'SearchExclude' ) ) {
|
196 |
add_filter( 'aws_index_product_ids', array( $this, 'search_exclude_filter' ) );
|
@@ -213,7 +208,7 @@ if ( ! class_exists( 'AWS_Integrations' ) ) :
|
|
213 |
}
|
214 |
|
215 |
// WP all import finish
|
216 |
-
add_action( 'pmxi_after_xml_import', array( $this, 'pmxi_after_xml_import' ) );
|
217 |
|
218 |
// BeRocket WooCommerce AJAX Products Filter
|
219 |
if ( defined( 'BeRocket_AJAX_filters_version' ) ) {
|
@@ -311,6 +306,11 @@ if ( ! class_exists( 'AWS_Integrations' ) ) :
|
|
311 |
include_once( AWS_DIR . '/includes/modules/class-aws-um.php' );
|
312 |
}
|
313 |
|
|
|
|
|
|
|
|
|
|
|
314 |
}
|
315 |
|
316 |
/*
|
@@ -1545,69 +1545,6 @@ if ( ! class_exists( 'AWS_Integrations' ) ) :
|
|
1545 |
|
1546 |
<?php }
|
1547 |
|
1548 |
-
/*
|
1549 |
-
* Wholesale plugin hide products
|
1550 |
-
*/
|
1551 |
-
public function wholesale_hide_products( $products ) {
|
1552 |
-
|
1553 |
-
$user_role = 'all';
|
1554 |
-
if ( is_user_logged_in() ) {
|
1555 |
-
$user = wp_get_current_user();
|
1556 |
-
$roles = ( array ) $user->roles;
|
1557 |
-
$user_role = $roles[0];
|
1558 |
-
}
|
1559 |
-
|
1560 |
-
$all_registered_wholesale_roles = unserialize( get_option( 'wwp_options_registered_custom_roles' ) );
|
1561 |
-
if ( ! is_array( $all_registered_wholesale_roles ) ) {
|
1562 |
-
$all_registered_wholesale_roles = array();
|
1563 |
-
}
|
1564 |
-
|
1565 |
-
$product_cat_wholesale_role_filter = get_option( 'wwpp_option_product_cat_wholesale_role_filter' );
|
1566 |
-
$categories_exclude_list = array();
|
1567 |
-
|
1568 |
-
if ( is_array( $product_cat_wholesale_role_filter ) && ! empty( $product_cat_wholesale_role_filter ) && $user_role !== 'administrator' ) {
|
1569 |
-
foreach( $product_cat_wholesale_role_filter as $term_id => $term_roles ) {
|
1570 |
-
if ( array_search( $user_role, $term_roles ) === false ) {
|
1571 |
-
$categories_exclude_list[] = $term_id;
|
1572 |
-
}
|
1573 |
-
}
|
1574 |
-
}
|
1575 |
-
|
1576 |
-
$new_products_array = array();
|
1577 |
-
|
1578 |
-
foreach( $products as $product ) {
|
1579 |
-
|
1580 |
-
$custom_fields = get_post_meta( $product['id'], 'wwpp_product_wholesale_visibility_filter' );
|
1581 |
-
$custom_price = get_post_meta( $product['id'], 'wholesale_customer_wholesale_price' );
|
1582 |
-
|
1583 |
-
if ( $custom_fields && ! empty( $custom_fields ) && $custom_fields[0] !== 'all' && $custom_fields[0] !== $user_role ) {
|
1584 |
-
continue;
|
1585 |
-
}
|
1586 |
-
|
1587 |
-
if ( is_user_logged_in() && !empty( $all_registered_wholesale_roles ) && isset( $all_registered_wholesale_roles[$user_role] )
|
1588 |
-
&& get_option( 'wwpp_settings_only_show_wholesale_products_to_wholesale_users', false ) === 'yes' && ! $custom_price ) {
|
1589 |
-
continue;
|
1590 |
-
}
|
1591 |
-
|
1592 |
-
if ( ! empty( $categories_exclude_list ) ) {
|
1593 |
-
$terms = wp_get_object_terms( $product['id'], 'product_cat' );
|
1594 |
-
if ( ! is_wp_error( $terms ) && ! empty( $terms ) ) {
|
1595 |
-
foreach ( $terms as $term ) {
|
1596 |
-
if ( array_search( $term->term_id, $categories_exclude_list ) !== false ) {
|
1597 |
-
continue 2;
|
1598 |
-
}
|
1599 |
-
}
|
1600 |
-
}
|
1601 |
-
}
|
1602 |
-
|
1603 |
-
$new_products_array[] = $product;
|
1604 |
-
|
1605 |
-
}
|
1606 |
-
|
1607 |
-
return $new_products_array;
|
1608 |
-
|
1609 |
-
}
|
1610 |
-
|
1611 |
/*
|
1612 |
* Remove products that was excluded with Search Exclude plugin ( https://wordpress.org/plugins/search-exclude/ )
|
1613 |
*/
|
@@ -1699,6 +1636,12 @@ if ( ! class_exists( 'AWS_Integrations' ) ) :
|
|
1699 |
if ( $term ) {
|
1700 |
$new_terms_arr[] = $term->term_id;
|
1701 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
1702 |
}
|
1703 |
if ( $new_terms_arr ) {
|
1704 |
$terms_arr = $new_terms_arr;
|
186 |
|
187 |
add_action( 'wp_head', array( $this, 'head_js_integration' ) );
|
188 |
|
|
|
|
|
|
|
|
|
|
|
189 |
// Search Exclude plugin
|
190 |
if ( class_exists( 'SearchExclude' ) ) {
|
191 |
add_filter( 'aws_index_product_ids', array( $this, 'search_exclude_filter' ) );
|
208 |
}
|
209 |
|
210 |
// WP all import finish
|
211 |
+
//add_action( 'pmxi_after_xml_import', array( $this, 'pmxi_after_xml_import' ) );
|
212 |
|
213 |
// BeRocket WooCommerce AJAX Products Filter
|
214 |
if ( defined( 'BeRocket_AJAX_filters_version' ) ) {
|
306 |
include_once( AWS_DIR . '/includes/modules/class-aws-um.php' );
|
307 |
}
|
308 |
|
309 |
+
// Wholesale plugin
|
310 |
+
if ( class_exists( 'WooCommerceWholeSalePrices' ) ) {
|
311 |
+
include_once( AWS_DIR . '/includes/modules/class-aws-wholesale.php' );
|
312 |
+
}
|
313 |
+
|
314 |
}
|
315 |
|
316 |
/*
|
1545 |
|
1546 |
<?php }
|
1547 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1548 |
/*
|
1549 |
* Remove products that was excluded with Search Exclude plugin ( https://wordpress.org/plugins/search-exclude/ )
|
1550 |
*/
|
1636 |
if ( $term ) {
|
1637 |
$new_terms_arr[] = $term->term_id;
|
1638 |
}
|
1639 |
+
if ( ! $term && strpos( $taxonomy, 'pa_' ) !== 0 ) {
|
1640 |
+
$term = get_term_by('slug', $term_slug, 'pa_' . $taxonomy );
|
1641 |
+
if ( $term ) {
|
1642 |
+
$new_terms_arr[] = $term->term_id;
|
1643 |
+
}
|
1644 |
+
}
|
1645 |
}
|
1646 |
if ( $new_terms_arr ) {
|
1647 |
$terms_arr = $new_terms_arr;
|
includes/class-aws-markup.php
CHANGED
@@ -90,7 +90,7 @@ if ( ! class_exists( 'AWS_Markup' ) ) :
|
|
90 |
|
91 |
$markup .= '<div class="aws-wrapper">';
|
92 |
|
93 |
-
$markup .= '<label
|
94 |
$markup .= '<input type="search" name="s" id="' . esc_attr( $input_id ) . '" value="' . get_search_query() . '" class="aws-search-field" placeholder="' . esc_attr( $placeholder ) . '" autocomplete="off" />';
|
95 |
$markup .= '<input type="hidden" name="post_type" value="product">';
|
96 |
$markup .= '<input type="hidden" name="type_aws" value="true">';
|
90 |
|
91 |
$markup .= '<div class="aws-wrapper">';
|
92 |
|
93 |
+
$markup .= '<label class="aws-search-label" for="' . esc_attr( $input_id ) . '">' . esc_attr( $placeholder ) . '</label>';
|
94 |
$markup .= '<input type="search" name="s" id="' . esc_attr( $input_id ) . '" value="' . get_search_query() . '" class="aws-search-field" placeholder="' . esc_attr( $placeholder ) . '" autocomplete="off" />';
|
95 |
$markup .= '<input type="hidden" name="post_type" value="product">';
|
96 |
$markup .= '<input type="hidden" name="type_aws" value="true">';
|
includes/class-aws-search-page.php
CHANGED
@@ -108,69 +108,17 @@ if ( ! class_exists( 'AWS_Search_Page' ) ) :
|
|
108 |
$paged = $query->query_vars['paged'] ? $query->query_vars['paged'] : 1;
|
109 |
$search_res = $this->search( $query, $posts_per_page, $paged );
|
110 |
|
111 |
-
|
112 |
-
$query->max_num_pages = ceil( count( $search_res['all'] ) / $posts_per_page );
|
113 |
|
114 |
-
|
115 |
-
$
|
116 |
-
|
117 |
-
$post_array = (array) $post_array;
|
118 |
-
$post_data = $post_array['post_data'];
|
119 |
-
|
120 |
-
$post->ID = ( isset( $post_array['parent_id'] ) && $post_array['parent_id'] ) ? $post_array['parent_id'] : $post_data->ID;
|
121 |
-
$post->site_id = get_current_blog_id();
|
122 |
-
|
123 |
-
if ( ! empty( $post_data->site_id ) ) {
|
124 |
-
$post->site_id = $post_data->site_id;
|
125 |
-
}
|
126 |
-
|
127 |
-
$post_return_args = array(
|
128 |
-
'post_type',
|
129 |
-
'post_author',
|
130 |
-
'post_name',
|
131 |
-
'post_status',
|
132 |
-
'post_title',
|
133 |
-
'post_parent',
|
134 |
-
'post_content',
|
135 |
-
'post_excerpt',
|
136 |
-
'post_date',
|
137 |
-
'post_date_gmt',
|
138 |
-
'post_modified',
|
139 |
-
'post_modified_gmt',
|
140 |
-
'post_mime_type',
|
141 |
-
'comment_count',
|
142 |
-
'comment_status',
|
143 |
-
'ping_status',
|
144 |
-
'menu_order',
|
145 |
-
'permalink',
|
146 |
-
'terms',
|
147 |
-
'post_meta'
|
148 |
-
);
|
149 |
|
150 |
-
|
151 |
-
if ( isset( $post_data->$key ) ) {
|
152 |
-
$post->$key = $post_data->$key;
|
153 |
-
}
|
154 |
-
}
|
155 |
|
156 |
-
$
|
157 |
|
158 |
-
if ( $post ) {
|
159 |
-
$new_posts[] = $post;
|
160 |
-
}
|
161 |
}
|
162 |
|
163 |
-
/**
|
164 |
-
* Filter search page results
|
165 |
-
* @since 2.01
|
166 |
-
* @param array $new_posts Posts array
|
167 |
-
* @param object $query Query
|
168 |
-
* @param array $this->data Search results data array
|
169 |
-
*/
|
170 |
-
$new_posts = apply_filters( 'aws_search_page_results', $new_posts, $query, $this->data );
|
171 |
-
|
172 |
-
$this->posts_by_query[spl_object_hash( $query )] = $new_posts;
|
173 |
-
|
174 |
global $wpdb;
|
175 |
|
176 |
return "SELECT * FROM $wpdb->posts WHERE 1=0";
|
@@ -208,21 +156,25 @@ if ( ! class_exists( 'AWS_Search_Page' ) ) :
|
|
208 |
|
209 |
$search_res = $this->search( $query, $posts_per_page, $paged );
|
210 |
|
211 |
-
|
212 |
-
$query->max_num_pages = ceil( count( $search_res['all'] ) / $posts_per_page );
|
213 |
|
214 |
-
|
215 |
-
$
|
216 |
-
}
|
217 |
|
218 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
219 |
|
220 |
}
|
221 |
return $posts;
|
222 |
}
|
223 |
|
224 |
/**
|
225 |
-
* Filter the posts array to contain
|
226 |
*
|
227 |
* @param array $posts
|
228 |
* @param object $query
|
@@ -340,11 +292,13 @@ if ( ! class_exists( 'AWS_Search_Page' ) ) :
|
|
340 |
public function facetwp_pre_filtered_post_ids( $post_ids, $obj ) {
|
341 |
if ( isset( $_GET['type_aws'] ) && isset( $_GET['s'] ) ) {
|
342 |
$search_res = $this->search( $obj->query, $obj->query_args['posts_per_page'], $obj->query_args['paged'] );
|
343 |
-
$
|
344 |
-
|
345 |
-
$
|
|
|
|
|
|
|
346 |
}
|
347 |
-
$post_ids = $products_ids;
|
348 |
}
|
349 |
return $post_ids;
|
350 |
}
|
@@ -355,10 +309,14 @@ if ( ! class_exists( 'AWS_Search_Page' ) ) :
|
|
355 |
* @param object $query
|
356 |
* @param int $posts_per_page
|
357 |
* @param int $paged
|
358 |
-
* @return array
|
359 |
*/
|
360 |
private function search( $query, $posts_per_page, $paged = 1 ) {
|
361 |
|
|
|
|
|
|
|
|
|
362 |
$s = $this->get_search_query( $query );
|
363 |
|
364 |
$hash = hash( 'md2', $s );
|
@@ -554,6 +512,75 @@ if ( ! class_exists( 'AWS_Search_Page' ) ) :
|
|
554 |
|
555 |
}
|
556 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
557 |
}
|
558 |
|
559 |
|
108 |
$paged = $query->query_vars['paged'] ? $query->query_vars['paged'] : 1;
|
109 |
$search_res = $this->search( $query, $posts_per_page, $paged );
|
110 |
|
111 |
+
if ( $search_res ) {
|
|
|
112 |
|
113 |
+
$query->found_posts = count( $search_res['all'] );
|
114 |
+
$query->max_num_pages = ceil( count( $search_res['all'] ) / $posts_per_page );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
|
116 |
+
$new_posts = $this->set_posts_objects( $search_res, $query );
|
|
|
|
|
|
|
|
|
117 |
|
118 |
+
$this->posts_by_query[spl_object_hash( $query )] = $new_posts;
|
119 |
|
|
|
|
|
|
|
120 |
}
|
121 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
global $wpdb;
|
123 |
|
124 |
return "SELECT * FROM $wpdb->posts WHERE 1=0";
|
156 |
|
157 |
$search_res = $this->search( $query, $posts_per_page, $paged );
|
158 |
|
159 |
+
if ( $search_res ) {
|
|
|
160 |
|
161 |
+
$query->found_posts = count( $search_res['all'] );
|
162 |
+
$query->max_num_pages = ceil( count( $search_res['all'] ) / $posts_per_page );
|
|
|
163 |
|
164 |
+
foreach ( $search_res['products'] as $product ) {
|
165 |
+
$products_ids[] = $product['id'];
|
166 |
+
}
|
167 |
+
|
168 |
+
$posts = $products_ids;
|
169 |
+
|
170 |
+
}
|
171 |
|
172 |
}
|
173 |
return $posts;
|
174 |
}
|
175 |
|
176 |
/**
|
177 |
+
* Filter the posts array to contain search query result. Pull previously queried posts.
|
178 |
*
|
179 |
* @param array $posts
|
180 |
* @param object $query
|
292 |
public function facetwp_pre_filtered_post_ids( $post_ids, $obj ) {
|
293 |
if ( isset( $_GET['type_aws'] ) && isset( $_GET['s'] ) ) {
|
294 |
$search_res = $this->search( $obj->query, $obj->query_args['posts_per_page'], $obj->query_args['paged'] );
|
295 |
+
if ( $search_res ) {
|
296 |
+
$products_ids = array();
|
297 |
+
foreach ( $search_res['all'] as $product ) {
|
298 |
+
$products_ids[] = $product['id'];
|
299 |
+
}
|
300 |
+
$post_ids = $products_ids;
|
301 |
}
|
|
|
302 |
}
|
303 |
return $post_ids;
|
304 |
}
|
309 |
* @param object $query
|
310 |
* @param int $posts_per_page
|
311 |
* @param int $paged
|
312 |
+
* @return array | bool
|
313 |
*/
|
314 |
private function search( $query, $posts_per_page, $paged = 1 ) {
|
315 |
|
316 |
+
if ( ! did_action( 'woocommerce_init' ) || ! did_action( 'woocommerce_after_register_taxonomy' ) || ! did_action( 'woocommerce_after_register_post_type' ) ) {
|
317 |
+
return false;
|
318 |
+
}
|
319 |
+
|
320 |
$s = $this->get_search_query( $query );
|
321 |
|
322 |
$hash = hash( 'md2', $s );
|
512 |
|
513 |
}
|
514 |
|
515 |
+
/*
|
516 |
+
* Set posts objects with data
|
517 |
+
*/
|
518 |
+
private function set_posts_objects( $search_res, $query ) {
|
519 |
+
|
520 |
+
$new_posts = array();
|
521 |
+
|
522 |
+
foreach ( $search_res['products'] as $post_array ) {
|
523 |
+
$post = new stdClass();
|
524 |
+
|
525 |
+
$post_array = (array) $post_array;
|
526 |
+
$post_data = $post_array['post_data'];
|
527 |
+
|
528 |
+
$post->ID = ( isset( $post_array['parent_id'] ) && $post_array['parent_id'] ) ? $post_array['parent_id'] : $post_data->ID;
|
529 |
+
$post->site_id = get_current_blog_id();
|
530 |
+
|
531 |
+
if ( ! empty( $post_data->site_id ) ) {
|
532 |
+
$post->site_id = $post_data->site_id;
|
533 |
+
}
|
534 |
+
|
535 |
+
$post_return_args = array(
|
536 |
+
'post_type',
|
537 |
+
'post_author',
|
538 |
+
'post_name',
|
539 |
+
'post_status',
|
540 |
+
'post_title',
|
541 |
+
'post_parent',
|
542 |
+
'post_content',
|
543 |
+
'post_excerpt',
|
544 |
+
'post_date',
|
545 |
+
'post_date_gmt',
|
546 |
+
'post_modified',
|
547 |
+
'post_modified_gmt',
|
548 |
+
'post_mime_type',
|
549 |
+
'comment_count',
|
550 |
+
'comment_status',
|
551 |
+
'ping_status',
|
552 |
+
'menu_order',
|
553 |
+
'permalink',
|
554 |
+
'terms',
|
555 |
+
'post_meta'
|
556 |
+
);
|
557 |
+
|
558 |
+
foreach ( $post_return_args as $key ) {
|
559 |
+
if ( isset( $post_data->$key ) ) {
|
560 |
+
$post->$key = $post_data->$key;
|
561 |
+
}
|
562 |
+
}
|
563 |
+
|
564 |
+
$post->awssearch = true; // Super useful for debugging
|
565 |
+
|
566 |
+
if ( $post ) {
|
567 |
+
$new_posts[] = $post;
|
568 |
+
}
|
569 |
+
}
|
570 |
+
|
571 |
+
/**
|
572 |
+
* Filter search page results
|
573 |
+
* @since 2.01
|
574 |
+
* @param array $new_posts Posts array
|
575 |
+
* @param object $query Query
|
576 |
+
* @param array $this->data Search results data array
|
577 |
+
*/
|
578 |
+
$new_posts = apply_filters( 'aws_search_page_results', $new_posts, $query, $this->data );
|
579 |
+
|
580 |
+
return $new_posts;
|
581 |
+
|
582 |
+
}
|
583 |
+
|
584 |
}
|
585 |
|
586 |
|
includes/modules/class-aws-wholesale.php
ADDED
@@ -0,0 +1,226 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Wholesale plugin support
|
4 |
+
*/
|
5 |
+
|
6 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
7 |
+
exit; // Exit if accessed directly.
|
8 |
+
}
|
9 |
+
|
10 |
+
if ( ! class_exists( 'AWS_Wholesale' ) ) :
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Class
|
14 |
+
*/
|
15 |
+
class AWS_Wholesale {
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Main AWS_Wholesale Instance
|
19 |
+
*
|
20 |
+
* Ensures only one instance of AWS_Wholesale is loaded or can be loaded.
|
21 |
+
*
|
22 |
+
* @static
|
23 |
+
* @return AWS_Wholesale - Main instance
|
24 |
+
*/
|
25 |
+
protected static $_instance = null;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Main AWS_Wholesale Instance
|
29 |
+
*
|
30 |
+
* Ensures only one instance of AWS_Wholesale is loaded or can be loaded.
|
31 |
+
*
|
32 |
+
* @static
|
33 |
+
* @return AWS_Wholesale - Main instance
|
34 |
+
*/
|
35 |
+
public static function instance() {
|
36 |
+
if ( is_null( self::$_instance ) ) {
|
37 |
+
self::$_instance = new self();
|
38 |
+
}
|
39 |
+
return self::$_instance;
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Constructor
|
44 |
+
*/
|
45 |
+
public function __construct() {
|
46 |
+
|
47 |
+
add_filter( 'aws_exclude_products', array( $this, 'exclude_products' ) );
|
48 |
+
|
49 |
+
add_filter( 'aws_search_tax_exclude', array( $this, 'exclude_tax' ), 10, 2 );
|
50 |
+
|
51 |
+
}
|
52 |
+
|
53 |
+
/*
|
54 |
+
* Restrict products
|
55 |
+
*/
|
56 |
+
public function exclude_products( $products_ids ) {
|
57 |
+
|
58 |
+
$excluded = $this->get_excluded_products();
|
59 |
+
$excluded_by_cat = $this->get_excluded_products_by_cat();
|
60 |
+
|
61 |
+
if ( ! empty( $excluded ) || ! empty( $excluded_by_cat ) ) {
|
62 |
+
$products_ids = array_merge( $products_ids, $excluded, $excluded_by_cat );
|
63 |
+
}
|
64 |
+
|
65 |
+
return $products_ids;
|
66 |
+
|
67 |
+
}
|
68 |
+
|
69 |
+
/*
|
70 |
+
* Restrict product_cat taxonomy
|
71 |
+
*/
|
72 |
+
public function exclude_tax( $excludes_array, $taxonomy ) {
|
73 |
+
|
74 |
+
if ( array_search( 'product_cat', $taxonomy ) !== false ) {
|
75 |
+
|
76 |
+
$user_role = $this->get_current_user();
|
77 |
+
$product_cat_wholesale_role_filter = get_option( 'wwpp_option_product_cat_wholesale_role_filter' );
|
78 |
+
$categories_exclude_list = array();
|
79 |
+
|
80 |
+
if ( is_array( $product_cat_wholesale_role_filter ) && ! empty( $product_cat_wholesale_role_filter ) && $user_role !== 'administrator' ) {
|
81 |
+
foreach( $product_cat_wholesale_role_filter as $term_id => $term_roles ) {
|
82 |
+
if ( array_search( $user_role, $term_roles ) === false ) {
|
83 |
+
$categories_exclude_list[] = $term_id;
|
84 |
+
}
|
85 |
+
}
|
86 |
+
}
|
87 |
+
|
88 |
+
$excludes_array = array_merge( $excludes_array, $categories_exclude_list );
|
89 |
+
|
90 |
+
}
|
91 |
+
|
92 |
+
return $excludes_array;
|
93 |
+
|
94 |
+
}
|
95 |
+
|
96 |
+
/*
|
97 |
+
* Get current user role
|
98 |
+
*/
|
99 |
+
private function get_current_user() {
|
100 |
+
|
101 |
+
$user_role = 'all';
|
102 |
+
if ( is_user_logged_in() ) {
|
103 |
+
$user = wp_get_current_user();
|
104 |
+
$roles = ( array ) $user->roles;
|
105 |
+
$user_role = $roles[0];
|
106 |
+
}
|
107 |
+
|
108 |
+
return $user_role;
|
109 |
+
|
110 |
+
}
|
111 |
+
|
112 |
+
/*
|
113 |
+
* Get excluded products by category
|
114 |
+
*/
|
115 |
+
private function get_excluded_products_by_cat() {
|
116 |
+
|
117 |
+
$user_role = $this->get_current_user();
|
118 |
+
|
119 |
+
$products_ids = array();
|
120 |
+
$product_cat_wholesale_role_filter = get_option( 'wwpp_option_product_cat_wholesale_role_filter' );
|
121 |
+
$categories_exclude_list = array();
|
122 |
+
|
123 |
+
if ( is_array( $product_cat_wholesale_role_filter ) && ! empty( $product_cat_wholesale_role_filter ) && $user_role !== 'administrator' ) {
|
124 |
+
foreach( $product_cat_wholesale_role_filter as $term_id => $term_roles ) {
|
125 |
+
if ( array_search( $user_role, $term_roles ) === false ) {
|
126 |
+
$categories_exclude_list[] = $term_id;
|
127 |
+
}
|
128 |
+
}
|
129 |
+
}
|
130 |
+
|
131 |
+
if ( $categories_exclude_list && ! empty( $categories_exclude_list ) ) {
|
132 |
+
|
133 |
+
$restricted_products = get_posts( array(
|
134 |
+
'posts_per_page' => -1,
|
135 |
+
'fields' => 'ids',
|
136 |
+
'post_type' => array( 'product', 'product_variation' ),
|
137 |
+
'post_status' => 'publish',
|
138 |
+
'ignore_sticky_posts' => true,
|
139 |
+
'suppress_filters' => true,
|
140 |
+
'has_password' => false,
|
141 |
+
'no_found_rows' => 1,
|
142 |
+
'orderby' => 'ID',
|
143 |
+
'order' => 'DESC',
|
144 |
+
'lang' => '',
|
145 |
+
'tax_query' => array(
|
146 |
+
'relation' => 'OR',
|
147 |
+
array(
|
148 |
+
'taxonomy' => 'product_cat',
|
149 |
+
'field' => 'id',
|
150 |
+
'terms' => $categories_exclude_list,
|
151 |
+
),
|
152 |
+
),
|
153 |
+
) );
|
154 |
+
|
155 |
+
if ( $restricted_products ) {
|
156 |
+
$products_ids = $restricted_products;
|
157 |
+
}
|
158 |
+
|
159 |
+
}
|
160 |
+
|
161 |
+
return $products_ids;
|
162 |
+
|
163 |
+
}
|
164 |
+
|
165 |
+
/*
|
166 |
+
* Get excluded products
|
167 |
+
*/
|
168 |
+
private function get_excluded_products() {
|
169 |
+
|
170 |
+
$user_role = $this->get_current_user();
|
171 |
+
|
172 |
+
$all_registered_wholesale_roles = unserialize( get_option( 'wwp_options_registered_custom_roles' ) );
|
173 |
+
if ( ! is_array( $all_registered_wholesale_roles ) ) {
|
174 |
+
$all_registered_wholesale_roles = array();
|
175 |
+
}
|
176 |
+
|
177 |
+
$products_ids = array();
|
178 |
+
$restricted_products = get_posts( array(
|
179 |
+
'posts_per_page' => -1,
|
180 |
+
'fields' => 'ids',
|
181 |
+
'post_type' => array( 'product', 'product_variation' ),
|
182 |
+
'post_status' => 'publish',
|
183 |
+
'ignore_sticky_posts' => true,
|
184 |
+
'suppress_filters' => true,
|
185 |
+
'has_password' => false,
|
186 |
+
'no_found_rows' => 1,
|
187 |
+
'orderby' => 'ID',
|
188 |
+
'order' => 'DESC',
|
189 |
+
'lang' => '',
|
190 |
+
'meta_query' => array(
|
191 |
+
array(
|
192 |
+
'key' => 'wwpp_product_wholesale_visibility_filter',
|
193 |
+
'compare' => 'EXISTS',
|
194 |
+
)
|
195 |
+
)
|
196 |
+
) );
|
197 |
+
|
198 |
+
if ( $restricted_products ) {
|
199 |
+
foreach ($restricted_products as $restricted_product_id) {
|
200 |
+
|
201 |
+
$custom_fields = get_post_meta( $restricted_product_id, 'wwpp_product_wholesale_visibility_filter' );
|
202 |
+
$custom_price = get_post_meta( $restricted_product_id, 'wholesale_customer_wholesale_price' );
|
203 |
+
|
204 |
+
if ( $custom_fields && ! empty( $custom_fields ) && $custom_fields[0] !== 'all' && $custom_fields[0] !== $user_role ) {
|
205 |
+
$products_ids[] = $restricted_product_id;
|
206 |
+
continue;
|
207 |
+
}
|
208 |
+
|
209 |
+
if ( is_user_logged_in() && !empty( $all_registered_wholesale_roles ) && isset( $all_registered_wholesale_roles[$user_role] )
|
210 |
+
&& get_option( 'wwpp_settings_only_show_wholesale_products_to_wholesale_users', false ) === 'yes' && ! $custom_price ) {
|
211 |
+
$products_ids[] = $restricted_product_id;
|
212 |
+
continue;
|
213 |
+
}
|
214 |
+
|
215 |
+
}
|
216 |
+
}
|
217 |
+
|
218 |
+
return $products_ids;
|
219 |
+
|
220 |
+
}
|
221 |
+
|
222 |
+
}
|
223 |
+
|
224 |
+
endif;
|
225 |
+
|
226 |
+
AWS_Wholesale::instance();
|
languages/advanced-woo-search.pot
CHANGED
@@ -695,6 +695,9 @@ msgstr ""
|
|
695 |
msgid "plugin settings page"
|
696 |
msgstr ""
|
697 |
|
|
|
|
|
|
|
698 |
msgid "Performance"
|
699 |
msgstr ""
|
700 |
|
695 |
msgid "plugin settings page"
|
696 |
msgstr ""
|
697 |
|
698 |
+
msgid "Please do not close the page."
|
699 |
+
msgstr ""
|
700 |
+
|
701 |
msgid "Performance"
|
702 |
msgstr ""
|
703 |
|
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.7
|
7 |
-
Stable tag: 2.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -167,6 +167,17 @@ Yep. This plugin is always compatible with the latest version of Woocommerce?
|
|
167 |
|
168 |
== Changelog ==
|
169 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
170 |
= 2.25 ( 2021-04-12 ) =
|
171 |
* Add - Royal theme integration
|
172 |
* Update - Aurum theme integration
|
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.7
|
7 |
+
Stable tag: 2.26
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
167 |
|
168 |
== Changelog ==
|
169 |
|
170 |
+
= 2.26 ( 2021-04-27 ) =
|
171 |
+
* Update - Tested with WC 5.2
|
172 |
+
* Update - Wholesale Pricing plugin support
|
173 |
+
* Update - BeRocket WooCommerce AJAX Products Filter support. Fix bug with slugs in URL for attributes filters
|
174 |
+
* Update - Disable automatic re-index after WP All Import plugin finish importing
|
175 |
+
* Update - Notice for plugin settings page
|
176 |
+
* Update - Search form markup for label tag
|
177 |
+
* Fix - Ajax request issue with sending parameters
|
178 |
+
* Fix - CoCart plugin issue with empty cart when performing AJAX search
|
179 |
+
* Fix - Bug with the empty search results page
|
180 |
+
|
181 |
= 2.25 ( 2021-04-12 ) =
|
182 |
* Add - Royal theme integration
|
183 |
* Update - Aurum theme integration
|