Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Incompatibility with WooCommerce Brands #2502

Closed
slaxxarn opened this issue Dec 8, 2021 · 4 comments · Fixed by #2560
Closed

BUG: Incompatibility with WooCommerce Brands #2502

slaxxarn opened this issue Dec 8, 2021 · 4 comments · Fixed by #2560
Assignees
Labels
bug Something isn't working
Milestone

Comments

@slaxxarn
Copy link

slaxxarn commented Dec 8, 2021

Describe the bug
When filtering on category pages with WooCommerce brands layered nav widget, nothing is shown because elasticpress adds a second tax query with field = slug and operator = and / or. While woocommerce brand adds/uses term_id as field and IN as operator.

Skärmavbild 2021-12-08 kl  08 57 58

The issue is in Facet.php and row 326 - 333. You add a tax query with field = slug and operator = AND / OR

foreach ( $selected_filters['taxonomies'] as $taxonomy => $filter ) {
	$tax_query[] = [
		'taxonomy' => isset( $attribute_taxonomies[ $taxonomy ] ) ? $attribute_taxonomies[ $taxonomy ] : $taxonomy,
		'field'    => 'slug',
		'terms'    => array_keys( $filter['terms'] ),
		'operator' => ( 'any' === $settings['match_type'] ) ? 'or' : 'and',
	];
}

Steps to Reproduce

  1. Add a brand
  2. Add products to the newly added brand
  3. Add the woocommerce brand layered nav widget in sidebar
  4. Go to the category page and filter
  5. Nothing is shown

Expected behavior
Don't add another tax query if a tax query for the same taxonomy already exists.

@slaxxarn slaxxarn added the bug Something isn't working label Dec 8, 2021
@mckdemps mckdemps added this to the 4.0.0 (beta 2) milestone Dec 21, 2021
@felipeelia
Copy link
Member

Related to #2129

@oscarssanchez
Copy link
Contributor

oscarssanchez commented Jan 11, 2022

Hi @slaxxarn ,

Would you mind providing if possible a copy of the plugin (if you can email that to the address in my profile that would be great) and a screenshare to check the difference with and without ElasticPress enabled?

I'm using version 1.6.24 of the plugin (as this is a paid plugin, we don't have access to more recent code) and really cannot use the legacy widget at all even with ElasticPress disabled. Thanks!

@slaxxarn
Copy link
Author

Hi @oscarssanchez,

We're using version 1.6.14 of the plugin. But widgets filtering by IN operator should not work if elasticpress is enabled, as you add a seperate tax query with AND or OR.

As I stated previously, could you not just check if a query for the taxonomy already exist before adding another one?

Will look into and test some other variations tomorrow, don't really have the time right not. Will get back in this issues after som testing.

@oscarssanchez
Copy link
Contributor

Closing per #2560

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants