Advanced AJAX Product Filters - Version 1.1.0.6

Version Description

  • Enhancement - Scroll to the top
  • Enhancement/Fix - Hash for old browsers added for better support
  • Enhancement/Fix - Sort by default WooCommerce value
  • Fix - out-of-stock filter working correctly
Download this release

Release Info

Developer dholovnia
Plugin Icon wp plugin Advanced AJAX Product Filters
Version 1.1.0.6
Comparing to
See all releases

Code changes from version 1.1.0.5 to 1.1.0.6

README.md DELETED
@@ -1,240 +0,0 @@
1
- === Advanced AJAX Product Filters ===
2
- Plugin Name: Advanced AJAX Product Filters
3
- Contributors: dholovnia, berocket
4
- Donate link: http://berocket.com
5
- Tags: filters, product filters, ajax product filters, advanced product filters, woocommerce filters, woocommerce product filters, woocommerce ajax product filters, widget, plugin
6
- Requires at least: 3.9
7
- Tested up to: 4.2.2
8
- Stable tag: 1.1.0.5
9
- License: GPLv2 or later
10
- License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
-
12
- WooCommerce AJAX Product Filters - advanced AJAX product filters plugin for WooCommerce.
13
-
14
- == Description ==
15
-
16
- WooCommerce AJAX Product Filters - advanced AJAX product filters plugin for WooCommerce. Add unlimited filters with one widget.
17
-
18
- = Features: =
19
-
20
- * AJAX Filters, Pagination and Sorting!
21
- * Unlimited Filters
22
- * Multiple User Interface Elements
23
- * SEO Friendly Urls ( with HTML5 PushState )
24
- * Filter Visibility By Product Category And Globals.
25
- * Accessible through shortcode
26
- * Filter box height limit with scroll themes
27
- * Working great with custom widget area
28
- * Drag and Drop Filter Building
29
- * And More...
30
-
31
- = Additional Features in Paid Plugin: =
32
-
33
- * Filter by Attribute, Tag and Custom Taxonomy
34
- * Customize filters look through admin
35
- * Tag Cloud for Tag filter
36
- * Slider can use strings as a value
37
- * Filters can be collapsed by clicking on title, option to collapse filter on start
38
- * Price Filter Custom Min and Max values
39
- * Add custom CSS on admin settings page
40
- * And More...
41
-
42
- = Paid Plugin Link =
43
- http://berocket.com/product/woocommerce-ajax-products-filter
44
-
45
- = Demo =
46
- http://woocommerce-product-filter.berocket.com
47
-
48
-
49
- = How It Works: =
50
- *check installation*
51
-
52
-
53
- = In recent updates: =
54
- * Jump to first page when filter changed
55
- * Option to add text before and after price input fields
56
- * Now only used values must be shown, not all
57
- * Products are limited by category we are in
58
- * Products amount on the first page fixed
59
- * Custom CSS class can be added per widget/filter
60
- * Update button - if added products will be updated only when user click Update button
61
- * Radio-box can be unselected by clicking it again
62
- * Minor fixes
63
-
64
-
65
-
66
- = Shortcode: =
67
- * In editor `[br_filters attribute=price type=slider title="Price Filter"]`
68
- * In PHP `do_shortcode('[br_filters attribute=price type=slider title="Price Filter"]');`
69
-
70
- = Shortcode Options: =
71
- * `attribute`(required) - product attribute, eg price or length. Don't forget that woocommerce adding pa_ suffix for created attributes.
72
- So if you create new attribute `jump` its name is `pa_jump`
73
- * `type`(required) - checkbox, radio, slider or select
74
- * `operator` - OR or AND
75
- * `title` - whatever you want to see as title. Can be empty
76
- * `product_cat` - parent category id
77
- * `cat_propagation` - should we propagate this filter to child categories? set 1 to turn this on
78
- * `height` - max filter box height. When height is met scroll will be added
79
- * `scroll_theme` - pretty clear name, scroll theme. Will be used if height is set and real height of box is more
80
-
81
-
82
- = Advanced Settings (Widget area): =
83
-
84
- * Product Category - if you want to pin your filter to category of the product this is good place to do it.
85
- Eg. You selling Phones and Cases for them. If user choose Category "Phones" filter "Have Wi-Fi" will appear
86
- but if user will choose "Cases" it will not be there as Admin set that "Have Wi-Fi" filter will be visible only on
87
- "Phones" category.
88
- * Filter Box Height - if your filter have too much options it is nice to limit height of the filter to not prolong
89
- the page too much. Scroll will appear.
90
- * Scroll theme - if "Filter Box Height" is set and box length is more than "Filter Box Height" scroll appear and
91
- how it looks depends on the theme you choose.
92
-
93
-
94
- = Advanced Settings (Plugin Settings): =
95
- * Plugin settings can be found in admin area, WooCommerce -> Product Filters
96
- * "No Products" message - Text that will be shown if no products found
97
- * "No Products" class - Add class and use it to style "No Products" box
98
- * Products selector - Selector for tag that is holding products
99
- * Sorting control - Take control over WooCommerce's sorting selectbox
100
- * SEO friendly urls - url will be changed when filter is selected/changed
101
- * Turn all filters off - If you want to hide filters without losing current configuration just turn them off
102
-
103
-
104
-
105
- == Installation ==
106
-
107
- = Step 1: =
108
- * First you need to add attributes to the products ( WooCommerce plugin should be installed and activated already )
109
- * Go to Admin area -> Products -> Attributes and add attributes your products will have, add them all
110
- * Click attribute's name where type is select and add values to it. Predefine product options
111
- * Go to your products and add attributes to each of them
112
-
113
- = Step 2: =
114
- * Install and activate plugin
115
- * First of all go to Admin area -> WooCommerce -> Product Filter and check what global options you can manage
116
- * After that go to Admin area -> Appearance -> Widgets
117
- * In Available Widgets ( left side of the screen ) find AJAX Product Filters
118
- * Drag it to Sidebar you choose
119
- * Enter title, choose attribute that will be used for filtering products, choose filter type,
120
- choose operator( whether product should have all selected values (AND) or one of them (OR) ),
121
- * Click save and go to your shop to check how it work.
122
- * That's it =)
123
-
124
-
125
- == Frequently Asked Questions ==
126
-
127
- ---
128
-
129
- == Screenshots ==
130
-
131
- ---
132
-
133
- == Changelog ==
134
-
135
- = 1.1.0.5 =
136
- * Enhancement - Jump to first page when filter changed
137
- * Enhancement - Option to add text before and after price input fields
138
- * Fix - Now only used values must be shown, not all
139
- * Fix - Products are limited by category we are in
140
- * Fix - Products amount on the first page is correct now
141
-
142
- = 1.1.0.4 =
143
- * Minor fix
144
-
145
- = 1.1.0.3 =
146
- * Enhancement - Custom CSS class can be added per widget/filter
147
- * Enhancement - Update button. If added products will be updated only when user click Update button
148
- * Enhancement - Radio-box can be unselected by clicking it again
149
- * Enhancement/Fix - Urls are shortened using better structure to save filters. `~` symbol is not used now
150
- * Fix - issue with shortened tags for shortcode.
151
- * Fix - on widgets page widget now has subcategories(hierarchy)
152
- * Fix - all categories are visible, not only that have products inside(popular)
153
- * Minor fixes
154
-
155
- = 1.1.0.2 =
156
- * Fix - another js issue that stops plugin from work
157
- * Fix - order by name, name_numeric and attribute ID wasn't working
158
-
159
- = 1.1.0.1 =
160
- * Fix - js issue that stops plugin from work
161
-
162
- = 1.1.0 =
163
- * Enhancement - Show all values - on plugin settings page you can enable option to show all values no matter if they are used or not
164
- * Enhancement - Values order - you can set values order when editing attribute. You can set how to order (by id, name or custom). If
165
- you set to order `by custom` you can drag&drop values up and down and set your own order.
166
- * Small fixes
167
-
168
- = 1.0.4.5 =
169
- * Enhancement - values order added. Now order of values can be controlled through attribute options
170
- * Enhancement/Fix - Better support for for category pages
171
- * Other small fixes
172
-
173
- = 1.0.4.4 =
174
- * Enhancement - adding callback for before_update, on_update, after_update events.
175
- * Other small fixes
176
-
177
- = 1.0.4.3 =
178
- * Enhancement - shortcode added
179
- * Critical/Fix - If slider match none its values wasn't counted
180
- * Enhancement/Fix - Changing attribute data location from url to action-element, providing more flexibility for template
181
- * Enhancement/Templating - Using full products loop instead of including product content template
182
- * Fix - Pagination with SEO url issue
183
-
184
- = 1.0.4.2 =
185
- * Enhancement/Fix - Better support for SEO urls with permalinks on/off
186
- * Fix - Critical bug that was returning incorrect products.
187
-
188
- = 1.0.4.1 =
189
- * Enhancement - Adding AJAX for pagination.
190
- * Enhancement - Adding PushState for pagination.
191
- * Enhancement/Fix - Pagination wasn't updating when filters used.
192
- * Enhancement/Fix - Text with amount of results (Eg "Showing all 2 results") wasn't updating after filters applied
193
- * Enhancement/Fix - When choosing Slider in admin Operator became hidden
194
- * Fix - All sliders except price wasn't working with SEO url
195
- * Fix - When changing attribute to/from price in admin all filters jumping
196
- * Fix - After filter applied all products was showed. Even those with Draft status.
197
-
198
- = 1.0.4 =
199
- * Enhancement - SEO friendly urls with possibility for users to share/bookmark their search. Will be shortened in future
200
- * Enhancement - Option added to turn SEO friendly urls on/off. Off by default as this is first version of this feature
201
- * Enhancement - Option to turn filters on/off globally
202
- * Enhancement - Option to take control over (default) sorting function, make it AJAXy and work with filters
203
- * Fix - Sorting remain correct after using filters. Sorting wasn't counted before
204
- * Fix - If there are 2 or more sliders they are not working correctly.
205
- * Fix - Values in slider was converted to float even when value ia not a price.
206
- * Fix - If there are 2 or more values for attribute it was not validated when used in slider.
207
-
208
- = 1.0.3.6 =
209
- * Fix - Removed actions that provide warning messages
210
- * Enhancement - Actions and filters inside plugin
211
-
212
- = 1.0.3.3 =
213
- * Enhancement/Fix - Showing products and options now depending on woocommerce_hide_out_of_stock_items option
214
- * Enhancement/Fix - If not enough data available( quantity of options < 2 ) filters will not be shown.
215
- * Fix - If in category, only products/options from this category will be shown
216
-
217
- = 1.0.3.2 =
218
- * Fix - wrong path was committed in previous version that killed plugin
219
-
220
- = 1.0.3 =
221
- * Enhancement - CSS and JavaScript files minimized
222
- * Enhancement - Settings page added
223
- * Enhancement - "No Products" message and it's class can be changed through admin
224
- * Enhancement - Option added that can enable control over sorting( if visible )
225
- * Enhancement - User can select several categories instead of one. Now you don't need to create several same filters
226
- for different categories.
227
- * Enhancement - Added option "include subcats?". if selected filter will be shown in selected categories and their
228
- subcategories
229
- * Fix - Adding support to themes that require product div to have "product" class
230
- * Fix - Slider in categories wasn't initialized
231
- * Fix - Subcategories wasn't working. Only Main categories were showing filters
232
- * Templating - return woocommerce/theme default structure for product
233
- * Templating - html parts moved to separate files in templates folder. You can overwrite them by creating folder
234
- "woocommerce-filters" and file with same name as in plugin templates folder.
235
-
236
- = 1.0.2 =
237
- * Fix - better support for older PHP versions
238
-
239
- = 1.0.1 =
240
- * First public version
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/widget.php CHANGED
@@ -76,14 +76,17 @@ class BeRocket_AAPF_Widget extends WP_Widget {
76
  'berocket_aapf_widget-script',
77
  'the_ajax_script',
78
  array(
79
- 'current_page_url' => preg_replace( "~paged?/[0-9]+/?~", "", home_url( $wp->request ) ),
80
- 'ajaxurl' => admin_url( 'admin-ajax.php' ),
81
- 'product_cat' => $wp_query_product_cat,
82
- 'products_holder_id' => @ $br_options['products_holder_id'],
83
- 'control_sorting' => @ $br_options['control_sorting'],
84
- 'seo_friendly_urls' => @ $br_options['seo_friendly_urls'],
85
  'berocket_aapf_widget_product_filters' => $post_temrs,
86
- 'user_func' => @ $br_options['user_func'],
 
 
 
87
  )
88
  );
89
 
@@ -406,7 +409,6 @@ class BeRocket_AAPF_Widget extends WP_Widget {
406
  $instance['css_class'] = strip_tags( $new_instance['css_class'] );
407
  $instance['text_before_price'] = strip_tags( $new_instance['text_before_price'] );
408
  $instance['text_after_price'] = strip_tags( $new_instance['text_after_price'] );
409
- $instance['first_page_jump'] = (int) $new_instance['first_page_jump'];
410
 
411
  if( $new_instance['height'] != 'auto' ) $new_instance['height'] = (float) $new_instance['height'];
412
  if( !$new_instance['height'] ) $new_instance['height'] = 'auto';
@@ -468,8 +470,15 @@ class BeRocket_AAPF_Widget extends WP_Widget {
468
  add_filter( 'woocommerce_pagination_args', array( __CLASS__, 'pagination_args' ) );
469
 
470
  $args = apply_filters( 'berocket_aapf_listener_wp_query_args', array() );
471
-
472
- $args['post__in'] = BeRocket_AAPF::limits_filter( array() );
 
 
 
 
 
 
 
473
  $args['post__in'] = BeRocket_AAPF::price_filter( $args['post__in'] );
474
  $args['post_status'] = 'publish';
475
  $args['post_type'] = 'product';
76
  'berocket_aapf_widget-script',
77
  'the_ajax_script',
78
  array(
79
+ 'current_page_url' => preg_replace( "~paged?/[0-9]+/?~", "", home_url( $wp->request ) ),
80
+ 'ajaxurl' => admin_url( 'admin-ajax.php' ),
81
+ 'product_cat' => $wp_query_product_cat,
82
+ 'products_holder_id' => @ $br_options['products_holder_id'],
83
+ 'control_sorting' => @ $br_options['control_sorting'],
84
+ 'seo_friendly_urls' => @ $br_options['seo_friendly_urls'],
85
  'berocket_aapf_widget_product_filters' => $post_temrs,
86
+ 'user_func' => @ $br_options['user_func'],
87
+ 'default_sorting' => get_option('woocommerce_default_catalog_orderby'),
88
+ 'first_page' => @ $br_options['first_page_jump'],
89
+ 'scroll_shop_top' => @ $br_options['scroll_shop_top'],
90
  )
91
  );
92
 
409
  $instance['css_class'] = strip_tags( $new_instance['css_class'] );
410
  $instance['text_before_price'] = strip_tags( $new_instance['text_before_price'] );
411
  $instance['text_after_price'] = strip_tags( $new_instance['text_after_price'] );
 
412
 
413
  if( $new_instance['height'] != 'auto' ) $new_instance['height'] = (float) $new_instance['height'];
414
  if( !$new_instance['height'] ) $new_instance['height'] = 'auto';
470
  add_filter( 'woocommerce_pagination_args', array( __CLASS__, 'pagination_args' ) );
471
 
472
  $args = apply_filters( 'berocket_aapf_listener_wp_query_args', array() );
473
+
474
+ $woocommerce_hide_out_of_stock_items = BeRocket_AAPF_Widget::woocommerce_hide_out_of_stock_items();
475
+ if( $woocommerce_hide_out_of_stock_items == 'yes' ) {
476
+ $args['post__in'] = BeRocket_AAPF::remove_out_of_stock( $args['post__in'] );
477
+ } else {
478
+ $args['post__in'] = array();
479
+ }
480
+
481
+ $args['post__in'] = BeRocket_AAPF::limits_filter( $args['post__in'] );
482
  $args['post__in'] = BeRocket_AAPF::price_filter( $args['post__in'] );
483
  $args['post_status'] = 'publish';
484
  $args['post_type'] = 'product';
js/widget.min.js CHANGED
@@ -9,7 +9,8 @@
9
  woocommerce_pagination_page = 1,
10
  berocket_aapf_widget_wait_for_button = false,
11
  berocket_aapf_widget_selected_filters = [],
12
- berocket_aapf_widget_first_page_jump = false;
 
13
 
14
  if( $('.woocommerce-pagination').hasClass('.woocommerce-pagination') ){
15
  woocommerce_pagination_page = parseInt( $('.woocommerce-pagination .current').text() );
@@ -171,7 +172,7 @@
171
  };
172
 
173
  if( the_ajax_script.seo_friendly_urls && 'history' in window && 'pushState' in history ) {
174
- updateLocation(args);
175
  args.location = location.href;
176
  }else{
177
  args.location = the_ajax_script.current_page_url;
@@ -194,10 +195,26 @@
194
  }
195
  args.location = args.location.replace(/\/?/,"") + "/?page=" + cur_page + "";
196
  }
 
 
 
 
 
 
 
 
 
197
  }
198
 
 
 
 
 
 
 
 
 
199
  $.post(the_ajax_script.ajaxurl, args, function (data) {
200
- berocket_aapf_widget_first_page_jump = false;
201
  $('.woocommerce-result-count').remove();
202
  $('.woocommerce-pagination').remove();
203
  $('form.woocommerce-ordering').remove();
@@ -228,12 +245,12 @@
228
  }, "json");
229
  }
230
 
231
- function updateLocation( args ){
232
  uri_request_array = [];
233
  uri_request = '';
234
  temp_terms = [];
235
 
236
- if( args.orderby && $('.woocommerce-ordering select.orderby option:first').attr('value') != args.orderby ){
237
  uri_request += 'order-'+args.orderby;
238
  }
239
  if( args.product_cat && args.product_cat > 0 ){
@@ -307,6 +324,10 @@
307
  });
308
  }
309
 
 
 
 
 
310
  cur_page = $('.woocommerce-pagination span.current').text();
311
  if( prev_page = parseInt( location.href.replace(/.+\/page\/([0-9]+).+/, "$1") ) ){
312
  if( ! parseInt( cur_page ) ){
@@ -404,10 +425,6 @@
404
  }
405
 
406
  $('.berocket_aapf_widget').on("change", "input, select", function(){
407
- if($(this).data('first_page') == '1' || berocket_aapf_widget_first_page_jump)
408
- berocket_aapf_widget_first_page_jump = true;
409
- else
410
- berocket_aapf_widget_first_page_jump = false;
411
  if($(this).attr('type') == 'checkbox' || $(this).attr('type') == 'radio')
412
  {
413
  if($(this).prop('checked'))
@@ -441,10 +458,6 @@
441
  $( '#'+$o.data('fields_1') ).val( vals[0] );
442
  $( '#'+$o.data('fields_2') ).val( vals[1] );
443
 
444
- if($(o).data('first_page') == '1' || berocket_aapf_widget_first_page_jump)
445
- berocket_aapf_widget_first_page_jump = true;
446
- else
447
- berocket_aapf_widget_first_page_jump = false;
448
  $('.slide div').each(function(i, obj)
449
  {
450
  if($(obj).data('taxonomy') == $(o).data('taxonomy'))
@@ -533,4 +546,54 @@
533
  });
534
 
535
  });
536
- })(jQuery);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  woocommerce_pagination_page = 1,
10
  berocket_aapf_widget_wait_for_button = false,
11
  berocket_aapf_widget_selected_filters = [],
12
+ berocket_aapf_widget_first_page_jump = the_ajax_script.first_page,
13
+ berocket_aapf_widget_scroll_shop_top = the_ajax_script.scroll_shop_top;
14
 
15
  if( $('.woocommerce-pagination').hasClass('.woocommerce-pagination') ){
16
  woocommerce_pagination_page = parseInt( $('.woocommerce-pagination .current').text() );
172
  };
173
 
174
  if( the_ajax_script.seo_friendly_urls && 'history' in window && 'pushState' in history ) {
175
+ updateLocation( args, true );
176
  args.location = location.href;
177
  }else{
178
  args.location = the_ajax_script.current_page_url;
195
  }
196
  args.location = args.location.replace(/\/?/,"") + "/?page=" + cur_page + "";
197
  }
198
+ if( the_ajax_script.seo_friendly_urls ) {
199
+ uri_request = updateLocation(args, false);
200
+ location.hash = '';
201
+ if( parseInt( cur_page ) )
202
+ location.hash = "paged="+parseInt( cur_page )+"&";
203
+ if( uri_request != "")
204
+ uri_request = 'filters=' + uri_request;
205
+ location.hash += 'filters=('+uri_request+')';
206
+ }
207
  }
208
 
209
+ if( berocket_aapf_widget_scroll_shop_top ) {
210
+ var top_scroll_offset = 0;
211
+ if( $( the_ajax_script.products_holder_id ).length ) {
212
+ top_scroll_offset = $( the_ajax_script.products_holder_id ).offset().top - 180;
213
+ if(top_scroll_offset < 0) top_scroll_offset = 0;
214
+ }
215
+ $("html, body").animate({ scrollTop: top_scroll_offset }, "slow");
216
+ }
217
  $.post(the_ajax_script.ajaxurl, args, function (data) {
 
218
  $('.woocommerce-result-count').remove();
219
  $('.woocommerce-pagination').remove();
220
  $('form.woocommerce-ordering').remove();
245
  }, "json");
246
  }
247
 
248
+ function updateLocation( args, pushstate ){
249
  uri_request_array = [];
250
  uri_request = '';
251
  temp_terms = [];
252
 
253
+ if( args.orderby && the_ajax_script.default_sorting != args.orderby ){
254
  uri_request += 'order-'+args.orderby;
255
  }
256
  if( args.product_cat && args.product_cat > 0 ){
324
  });
325
  }
326
 
327
+ if( !pushstate ) {
328
+ return uri_request;
329
+ }
330
+
331
  cur_page = $('.woocommerce-pagination span.current').text();
332
  if( prev_page = parseInt( location.href.replace(/.+\/page\/([0-9]+).+/, "$1") ) ){
333
  if( ! parseInt( cur_page ) ){
425
  }
426
 
427
  $('.berocket_aapf_widget').on("change", "input, select", function(){
 
 
 
 
428
  if($(this).attr('type') == 'checkbox' || $(this).attr('type') == 'radio')
429
  {
430
  if($(this).prop('checked'))
458
  $( '#'+$o.data('fields_1') ).val( vals[0] );
459
  $( '#'+$o.data('fields_2') ).val( vals[1] );
460
 
 
 
 
 
461
  $('.slide div').each(function(i, obj)
462
  {
463
  if($(obj).data('taxonomy') == $(o).data('taxonomy'))
546
  });
547
 
548
  });
549
+ })(jQuery);
550
+
551
+ function load_hash_test() {
552
+ hash = location.hash;
553
+ if( location.hash != "")
554
+ location.hash = "";
555
+ test_loc = location.href;
556
+ reload = false;
557
+ var filtersRegex = /filters=\((.*)\)/;
558
+ if( ( filters_hash = filtersRegex.exec(hash) ) != null ) {
559
+ if( test_loc.indexOf('?') != -1 ) {
560
+ href_param = test_loc.split('?');
561
+ if(href_param[1].indexOf('filters=') != -1) {
562
+ href_params_array = href_param[1].split('&');
563
+ for( var i = 0; i < href_params_array.length; i++ ) {
564
+ if( href_params_array[i].indexOf('filters=') != -1) {
565
+ test_loc = test_loc.replace(href_params_array[i],filters_hash[1]).replace(/#/,"").replace('&&','&');
566
+ }
567
+ }
568
+ } else {
569
+ test_loc = test_loc.replace(/#/,"")+"&"+filters_hash[1];
570
+ }
571
+ } else {
572
+ test_loc = test_loc.replace(/#/,"")+"?"+filters_hash[1];
573
+ }
574
+ reload = true;
575
+ }
576
+ var filtersRegex = /paged=([0-9]+)/;
577
+ if( ( filters_hash = filtersRegex.exec(hash) ) != null ) {
578
+ if( test_loc.indexOf('?') != -1 ) {
579
+ href_param = test_loc.split('?');
580
+ if(href_param[1].indexOf('paged=') != -1) {
581
+ href_params_array = href_param[1].split('&');
582
+ for( var i = 0; i < href_params_array.length; i++ ) {
583
+ if( href_params_array[i].indexOf('filters=') != -1) {
584
+ test_loc = test_loc.replace(href_params_array[i],filters_hash[0]).replace(/#/,"").replace('&&','&');
585
+ }
586
+ }
587
+ } else {
588
+ test_loc = test_loc.replace(/#/,"")+"&"+filters_hash[0];
589
+ }
590
+ } else {
591
+ test_loc = test_loc.replace(/#/,"")+"?"+filters_hash[0];
592
+ }
593
+ reload = true;
594
+ }
595
+ if(reload) {
596
+ location.href = test_loc;
597
+ }
598
+ }
599
+ load_hash_test();
readme.txt CHANGED
@@ -3,9 +3,9 @@ Plugin Name: Advanced AJAX Product Filters
3
  Contributors: dholovnia, berocket
4
  Donate link: http://berocket.com
5
  Tags: filters, product filters, ajax product filters, advanced product filters, woocommerce filters, woocommerce product filters, woocommerce ajax product filters, widget, plugin
6
- Requires at least: 3.9
7
  Tested up to: 4.2.2
8
- Stable tag: 1.1.0.5
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -51,14 +51,13 @@ http://woocommerce-product-filter.berocket.com
51
 
52
 
53
  = In recent updates: =
 
 
 
 
54
  * Jump to first page when filter changed
55
  * Option to add text before and after price input fields
56
  * Now only used values must be shown, not all
57
- * Products are limited by category we are in
58
- * Products amount on the first page fixed
59
- * Custom CSS class can be added per widget/filter
60
- * Update button - if added products will be updated only when user click Update button
61
- * Radio-box can be unselected by clicking it again
62
  * Minor fixes
63
 
64
 
@@ -132,6 +131,12 @@ http://woocommerce-product-filter.berocket.com
132
 
133
  == Changelog ==
134
 
 
 
 
 
 
 
135
  = 1.1.0.5 =
136
  * Enhancement - Option to add text before and after price input fields
137
  * Enhancement - Jump to first page when filter changed
3
  Contributors: dholovnia, berocket
4
  Donate link: http://berocket.com
5
  Tags: filters, product filters, ajax product filters, advanced product filters, woocommerce filters, woocommerce product filters, woocommerce ajax product filters, widget, plugin
6
+ Requires at least: 4.0
7
  Tested up to: 4.2.2
8
+ Stable tag: 1.1.0.6
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
51
 
52
 
53
  = In recent updates: =
54
+ * Scroll to the top
55
+ * Hash for old browsers added for better support
56
+ * Sort by default WooCommerce value
57
+ * Fixed out-of-stock filter
58
  * Jump to first page when filter changed
59
  * Option to add text before and after price input fields
60
  * Now only used values must be shown, not all
 
 
 
 
 
61
  * Minor fixes
62
 
63
 
131
 
132
  == Changelog ==
133
 
134
+ = 1.1.0.6 =
135
+ * Enhancement - Scroll to the top
136
+ * Enhancement/Fix - Hash for old browsers added for better support
137
+ * Enhancement/Fix - Sort by default WooCommerce value
138
+ * Fix - out-of-stock filter working correctly
139
+
140
  = 1.1.0.5 =
141
  * Enhancement - Option to add text before and after price input fields
142
  * Enhancement - Jump to first page when filter changed
templates/admin-settings.php CHANGED
@@ -64,6 +64,20 @@
64
  <span style="color:#666666;margin-left:2px;">Check if you want to show not used attribute values too</span>
65
  </td>
66
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  </table>
68
  </div>
69
  <div id="design" class="tab-item">
64
  <span style="color:#666666;margin-left:2px;">Check if you want to show not used attribute values too</span>
65
  </td>
66
  </tr>
67
+ <tr>
68
+ <th scope="row">Jump to first page</th>
69
+ <td>
70
+ <input name="br_filters_options[first_page_jump]" type='checkbox' value='1' <?php if( @$options['first_page_jump'] ) echo "checked='checked'";?>/>
71
+ <span style="color:#666666;margin-left:2px;">Check if you want load first page after filters change</span>
72
+ </td>
73
+ </tr>
74
+ <tr>
75
+ <th scope="row">Scroll page to the top</th>
76
+ <td>
77
+ <input name="br_filters_options[scroll_shop_top]" type='checkbox' value='1' <?php if( @$options['scroll_shop_top'] ) echo "checked='checked'";?>/>
78
+ <span style="color:#666666;margin-left:2px;">Check if you want scroll page to the top of shop after filters change</span>
79
+ </td>
80
+ </tr>
81
  </table>
82
  </div>
83
  <div id="design" class="tab-item">
templates/admin.php CHANGED
@@ -108,11 +108,5 @@
108
  <?php endforeach; ?>
109
  </select>
110
  </p>
111
- <p>
112
- <label>
113
- <input type="checkbox" name="<?php echo $this->get_field_name( 'first_page_jump' ); ?>" <?php if ( $instance['first_page_jump'] ) echo 'checked'; ?> value="1" class="berocket_aapf_widget_admin_height_input" />
114
- Jump to first page?
115
- </label>
116
- </p>
117
  </div>
118
  </div>
108
  <?php endforeach; ?>
109
  </select>
110
  </p>
 
 
 
 
 
 
111
  </div>
112
  </div>
templates/checkbox.php CHANGED
@@ -15,7 +15,7 @@ if ( @ $terms ):
15
  ?>
16
  <li>
17
  <span>
18
- <input id='checkbox_<?=$term->term_id?>' class="<?php echo @ $uo['class']['checkbox_radio'] ?> checkbox_<?php echo $term->term_id ?>" type='checkbox' data-first_page='<?php echo (($first_page_jump) ? '1' : '0'); ?>'
19
  data-term_id='<?php echo $term->term_id ?>' data-taxonomy='<?php echo $term->taxonomy ?>' data-operator='<?php echo $operator ?>'
20
  <?php
21
  if( @ $_POST['terms'] ){
15
  ?>
16
  <li>
17
  <span>
18
+ <input id='checkbox_<?=$term->term_id?>' class="<?php echo @ $uo['class']['checkbox_radio'] ?> checkbox_<?php echo $term->term_id ?>" type='checkbox'
19
  data-term_id='<?php echo $term->term_id ?>' data-taxonomy='<?php echo $term->taxonomy ?>' data-operator='<?php echo $operator ?>'
20
  <?php
21
  if( @ $_POST['terms'] ){
templates/radio.php CHANGED
@@ -6,7 +6,7 @@ if ( $terms ):
6
  <span>
7
  <input class="<?php echo @ $uo['class']['checkbox_radio'] ?> radio_<?php echo $term->term_id?>" type='radio' id='radio_<?php echo $term->term_id?>_<?php echo $random_name ?>'
8
  name='radio_<?php echo $term->taxonomy ?>_<?php echo $x ?>_<?php echo $random_name ?>'
9
- data-term_id='<?php echo $term->term_id ?>' data-taxonomy='<?php echo $term->taxonomy ?>' data-operator='<?php echo $operator ?>' data-first_page='<?php echo (($first_page_jump) ? '1' : '0'); ?>'
10
  <?php
11
  if( @ $_POST['terms'] ){
12
  foreach( $_POST['terms'] as $p_term ){
6
  <span>
7
  <input class="<?php echo @ $uo['class']['checkbox_radio'] ?> radio_<?php echo $term->term_id?>" type='radio' id='radio_<?php echo $term->term_id?>_<?php echo $random_name ?>'
8
  name='radio_<?php echo $term->taxonomy ?>_<?php echo $x ?>_<?php echo $random_name ?>'
9
+ data-term_id='<?php echo $term->term_id ?>' data-taxonomy='<?php echo $term->taxonomy ?>' data-operator='<?php echo $operator ?>'
10
  <?php
11
  if( @ $_POST['terms'] ){
12
  foreach( $_POST['terms'] as $p_term ){
templates/select.php CHANGED
@@ -4,7 +4,7 @@
4
  <option data-taxonomy='<?php echo $terms[0]->taxonomy ?>' value=''>Any</option>
5
  <?php foreach( $terms as $term ): ?>
6
  <option value='<?php echo $term->term_id?>' data-term_id='<?php echo $term->term_id ?>' data-taxonomy='<?php echo $term->taxonomy ?>'
7
- data-operator='<?php echo $operator ?>' data-first_page='<?php echo (($first_page_jump) ? '1' : '0'); ?>'
8
  <?php
9
  if( @ $_POST['terms'] ){
10
  foreach( $_POST['terms'] as $p_term ){
4
  <option data-taxonomy='<?php echo $terms[0]->taxonomy ?>' value=''>Any</option>
5
  <?php foreach( $terms as $term ): ?>
6
  <option value='<?php echo $term->term_id?>' data-term_id='<?php echo $term->term_id ?>' data-taxonomy='<?php echo $term->taxonomy ?>'
7
+ data-operator='<?php echo $operator ?>'
8
  <?php
9
  if( @ $_POST['terms'] ){
10
  foreach( $_POST['terms'] as $p_term ){
templates/slider.php CHANGED
@@ -12,7 +12,6 @@
12
  <div class='<?php echo $slider_class ?>' data-taxonomy='<?php echo $filter_slider_id ?>'
13
  data-min='<?php echo $min ?>' data-max='<?php echo $max ?>'
14
  data-value1='<?php echo $slider_value1 ?>' data-value2='<?php echo $slider_value2 ?>'
15
- data-first_page='<?php echo (($first_page_jump) ? '1' : '0'); ?>'
16
  data-fields_1='text_<?php echo $filter_slider_id . $unique ?>_1'
17
  data-fields_2='text_<?php echo $filter_slider_id . $unique ?>_2'></div>
18
  </span>
12
  <div class='<?php echo $slider_class ?>' data-taxonomy='<?php echo $filter_slider_id ?>'
13
  data-min='<?php echo $min ?>' data-max='<?php echo $max ?>'
14
  data-value1='<?php echo $slider_value1 ?>' data-value2='<?php echo $slider_value2 ?>'
 
15
  data-fields_1='text_<?php echo $filter_slider_id . $unique ?>_1'
16
  data-fields_2='text_<?php echo $filter_slider_id . $unique ?>_2'></div>
17
  </span>
woocommerce-filters.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Advanced AJAX Product Filters for WooCommerce
4
  * Plugin URI: http://berocket.com/wp-plugins/product-filters
5
  * Description: Advanced AJAX Product Filters for WooCommerce
6
- * Version: 1.1.0.5
7
  * Author: BeRocket
8
  * Author URI: http://berocket.com
9
  */
@@ -111,6 +111,30 @@ class BeRocket_AAPF {
111
  return $query;
112
  }
113
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
  public static function limits_filter( $filtered_posts ){
115
  global $wpdb;
116
 
3
  * Plugin Name: Advanced AJAX Product Filters for WooCommerce
4
  * Plugin URI: http://berocket.com/wp-plugins/product-filters
5
  * Description: Advanced AJAX Product Filters for WooCommerce
6
+ * Version: 1.1.0.6
7
  * Author: BeRocket
8
  * Author URI: http://berocket.com
9
  */
111
  return $query;
112
  }
113
 
114
+ public static function remove_out_of_stock( $filtered_posts ){
115
+ global $wpdb;
116
+ $matched_products_query = $wpdb->get_results( "
117
+ SELECT DISTINCT ID, post_parent, post_type FROM $wpdb->posts
118
+ INNER JOIN $wpdb->postmeta as meta ON ID = meta.post_id
119
+ WHERE post_type IN ( 'product', 'product_variation' ) AND post_status = 'publish'
120
+ AND meta_key = '_stock_status' AND meta_value != 'outofstock'", OBJECT_K );
121
+ $matched_products = array( 0 );
122
+ foreach ( $matched_products_query as $product ) {
123
+ if ( $product->post_type == 'product' )
124
+ $matched_products[] = $product->ID;
125
+ if ( $product->post_parent > 0 && ! in_array( $product->post_parent, $matched_products ) )
126
+ $matched_products[] = $product->post_parent;
127
+ }
128
+ $matched_products = @ array_unique( $matched_products );
129
+
130
+ if ( sizeof( $filtered_posts ) == 0) {
131
+ $filtered_posts = $matched_products;
132
+ } else {
133
+ $filtered_posts = array_intersect( $filtered_posts, $matched_products );
134
+ }
135
+ return (array) $filtered_posts;
136
+ }
137
+
138
  public static function limits_filter( $filtered_posts ){
139
  global $wpdb;
140