Commit Graph

138 Commits

Author SHA1 Message Date
Nestor Soriano 681401850a Adjustments in the items count calculation on the nav filtering widget.
The calculations are now consistent with the change made to the
visibility of the variable products when using one or multiple filters.
2020-07-28 09:01:55 +02:00
Néstor Soriano e9d692f455 Apply suggestions from code review
Mostly adding "since 4.4.0" annotations and updating
db update functions from 4.2 to 4.4.

Co-authored-by: Claudio Sanches <contato@claudiosanches.com>
2020-07-28 09:01:55 +02:00
Nestor Soriano 9de1306c21 Fix counters in nav filtering widgets for variable products.
After the change that registers variation attributes as terms
(in addition to reigstering them as post meta) it is now time
to modify the get_filtered_term_product_counts methods in
WC_Widget_Layered_Nav so that it works consistently for both
variable and non-variable products. The logic for the counters
is now as follows:

with OR operator:
- Simple products: count the attributes of all visible products
  (unchanged behavior).
- Variable products: count attributes corresponding to
  visible variations.

with AND operator:
- Simple products: count the attributes of visible products but only
  for products that have all the selected (unchanged behavior).
- Variable products: find all the products for which all the variations
  corresponding to the selected attributes exist and are visible,
  then count the attributes corresponding to the visible variations
  of those products.

A product is "visible" if it's published, not excluded for catalog,
and has stock. Additionally, a variable product will not be considered
visible if the parent product is not.
2020-07-28 08:55:55 +02:00
Nestor Soriano c27283dffe Fix code sniffer errors in some files.
Fixed files:

includes/abstracts/abstract-wc-product.php
includes/class-wc-query.php
includes/wc-template-functions.php
includes/widgets/class-wc-widget-layered-nav.php
templates/loop/result-count.php
tests/unit-tests/util/class-wc-tests-wc-query.php
2020-07-28 08:47:29 +02:00
Mike Jolley 16a0a3e27e Update from master 2019-03-05 19:03:01 +00:00
Mike Jolley 7def966e4f Impoved JSON handling 2019-02-20 12:00:47 +00:00
Mike Jolley 1efe7747a8 merge conflict 2019-02-08 13:08:55 +00:00
Mike Jolley b2c33b8e34 Merge branch 'master' into performance/slow-term-queries 2019-02-07 13:49:48 +00:00
Mike Jolley 74cd1ced37 Merge branch 'fix/20710' 2019-01-31 13:37:02 +00:00
Mike Jolley 5b57cb5356 Layered nav should use base link 2019-01-30 16:29:01 +00:00
Mike Jolley fa58f3bb9f Lax the kses here - link and name is already escaped. 2019-01-30 16:10:48 +00:00
Mike Jolley a38add7ac8 No need for default sorting 2019-01-25 19:55:25 +00:00
claudiulodro 8078e6bfc2 Simplified title check that works on all wc widgets 2019-01-24 10:47:05 -08:00
Ron Rennick 8709351994 update function name to `wc_attribute_taxonomy_slug` 2019-01-23 11:11:27 -04:00
Ron Rennick b868b484f7 fix merge conflicts 2019-01-23 10:53:42 -04:00
Mike Jolley 0c76db4093 Get instance setting defaults so it shows in customiser before save 2019-01-04 16:11:36 +00:00
Gerhard 7074b0933c Don't wrap wp_json_encode string in quotes, it already does it for us. 2018-12-10 10:14:56 +02:00
Ron Rennick c1ad273a03 replace all remaining str_replace( 'pa_', ... with wc_attribute_taxonomy_name_raw(...) 2018-12-03 11:32:33 -04:00
claudiulodro 67d80c35d8 Update cache key to consistently work with all types of chars 2018-09-20 08:21:39 -07:00
Gerhard Potgieter f28002f257 Use wp_json_encode instead of esc_js. Hat tip @dtugend 2018-09-10 14:35:55 +02:00
Gerhard Potgieter 16b2abe8cd Remove charset, WP will load site charset by default. We need to do esc_js first before wp_specialchars_decode to avoid esc_js to encode double quotes again. 2018-09-10 11:58:39 +02:00
Gerhard Potgieter 6b3feb0417 Decode encoded special chars for Any string label used in the layered nav widget. 2018-09-10 10:49:25 +02:00
Rodrigo Primo 20fd569a55 Fix clearing filters in "Filter products by attribute" widget
This commit fixes an issue that was making it impossible to clear filters in the "Filter products by attribute" widget when the attribute name contained non-ASCII characters. The problem was caused by a call to sanitize_title() which doesn't seem necessary as it is sanitizing one of the widget parameters which is already sanitized in 679d719368/includes/widgets/class-wc-widget-layered-nav.php (L116). So this commit simply removes the sanitize_title() call. Even if we needed to sanitize the variable `$taxonomy`, it would be better to use sanitize_text_input_field() or wc_sanitize_taxonomy_name() as sanitize_title() will replace accented characters.

For more about the problem that is fixed by this commit see #21028
2018-08-14 11:45:57 -03:00
Mike Jolley 679d719368 Use correct escaping on placeholder
Use correct escaping on placeholder - this is not HTML, this is an attribute output within javascript code.

Closes #20360
2018-06-04 10:53:10 +01:00
Mike Jolley 06418f67e5
Merge pull request #19225 from roylindauer/17355-SplitAndFilter
Split layered nav transient per issue #17355
2018-03-14 12:50:54 +00:00
Roy Lindauer b151480e6b fix indentation issues 2018-03-13 15:34:47 -07:00
Claudio Sanches cbb1271b2c Fixed class-wc-widget-product-categories.php PHPCS violations 2018-03-09 17:28:08 -03:00
Claudio Sanches e87c309b01 Fixed class-wc-widget-layered-nav.php PHPCS violations 2018-03-09 17:10:03 -03:00
Roy Lindauer bb9afb29be
cached_counts would not be defined if cache is false 2018-03-06 07:32:12 -08:00
Roy Lindauer 4147038e93 Add filter to control caching of layered nav counts. Split cached layered nav counts by taxonomy 2018-03-02 22:14:20 -08:00
Boro Sitnikovski 080ece9588 Change method name 2017-12-14 15:37:42 +01:00
Boro Sitnikovski e1b753122e Deprecate the function as a whole 2017-12-14 10:23:51 +01:00
claudiulodro d60456cc73 Resolve conflicts and bring up to date with master 2017-12-04 13:56:59 -08:00
Mike Jolley 208b2d1b81 Slugs are encoded, so decode before outputting to the form
Fixes #17845
2017-11-21 16:50:33 +00:00
Mike Jolley 46775c2f7d standards 2017-11-20 12:14:05 +00:00
Alexandre GASNE 0018b4349e Fix: Apostrophe wrongly escaped for price nav filter and widget nav filters 2017-11-18 20:11:53 +01:00
Mike Jolley 1a7d7dd127 Widget base url 2017-11-09 11:24:29 +00:00
Mike Jolley 1b22d97be2 Combined get_page_base_url 2017-11-09 11:16:47 +00:00
Gerhard Potgieter 21377fe5a7 input to button for submit in class-wc-widget-layered-nav.php 2017-11-07 10:56:36 +02:00
Gerhard Potgieter 364d266def PHPCS fixes for class-wc-widget-layered-nav.php 2017-11-07 10:55:27 +02:00
Mike Jolley a6e5a684d0 Merge branch 'pr/17134' 2017-10-27 16:07:41 +01:00
Mike Jolley e5038e737e Standards 2017-10-27 16:07:30 +01:00
Mike Jolley 35f5140e1c Merge branch 'pr/17137' 2017-10-27 15:59:56 +01:00
Mike Jolley 47bb63733b Standards 2017-10-27 15:59:47 +01:00
Mike Jolley 2d021e3786 Merge pull request #17077 from grosssmutttr/patch-2
Update class-wc-widget-layered-nav.php - Avoid duplicate content
2017-10-27 15:19:48 +01:00
grosssmutttr 1ccec7d156 class-wc-widget-layered-nav.php - Crawling Budget
Additional optimization to save up crawling budget.
Added $link = str_replace('%2C', ',', $link); on line 513

https://mydomain.com/produkt-kategorie/my-category/?filter_filter-color=orange,black

If you add another filter it encodes the existing commas:
https://mydomain.com/produkt-kategorie/my-category/?filter_filter-color=orange%2Cblack&filter_manufacturer=adidas&filter_cut=men.children

So sometimes you have "," as seperator and sometimes you have encoded "%2C".

After implementing this pull-request the seperator stays ",":
https://mydomain.com/produkt-kategorie/my-category/?filter_filter-farbe=orange,black&filter_manufacturer=adidas&filter_cut=men.children

This pull request belongs to the optimization https://github.com/woocommerce/woocommerce/pull/17134 to save up crawling budget,
2017-10-11 14:47:00 +02:00
grosssmutttr d9f0bd5e92 Keep link structure - prevent duplicate content
Added asort($current_filter) so the urls always look the same and there are not millions of urls possibilities when adding multiple filters.

Current url example:
https://myurl.com/produkt-kategorie/mycategory/?filter_filter-color=yellow,brown,blue,red
https://myurl.com/produkt-kategorie/mycategory/?filter_filter-color=yellow,blue,red,brown
https://myurl.com/produkt-kategorie/mycategory/?filter_filter-color=blue,yellow,red,brown
...

With asort you only have this url:
https://myurl.com/produkt-kategorie/mycategory/?filter_filter-color=blue,brown,red,yellow

So it is independent on the sequence a user adds a filter
2017-10-11 08:33:46 +02:00
claudiulodro f1dac6f3ac Use esc_js instead of addslashes 2017-10-09 11:37:09 -07:00
claudiulodro 97d7ae7df8 Missing semicolon 2017-10-09 11:16:24 -07:00
claudiulodro 2ccd44afa7 Translate "no matches" message 2017-10-09 11:10:32 -07:00