Skip to content

Conversation

@Konamiman
Copy link
Contributor

@Konamiman Konamiman commented Feb 5, 2021

All Submissions:

Changes proposed in this Pull Request:

The price filtering query wasn't working properly when there are variations with different prices: if at least one variation was
outside of the price range but other were inside, the product wasn't being listed.

This pull request fixes the generation of the where clause in WC_Query->price_filter_post_clauses to account for this case.

Closes #25261

How to test the changes in this Pull Request:

Create a variable product having two variations with prices 1000 and 1200. Install the price filtering widget and try the following combinations of min and max price:

  1. 0, 950
  2. 0,1000
  3. 0, 1050
  4. 1000, 1100
  5. 1050, 1100
  6. 1050, 1300
  7. 1200, 1300
  8. 1250, 1300

The product should not be listed in the cases 1 and 7, in all the other cases it should be listed.

Note: if you don't have products with a price higher than 1220 you won't be able to use the widget for the last three combinations, but you can just modify the query string and reload manually.

Note: that's not a complete fix and will 100% work only when the "Hide out of stock products" option is disable. See this comment in the original issue.

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully run tests with your changes locally?

Changelog entry

Fix - price filtering not working properly with variable products whose variations have different prices.

The price filtering query wasn't working properly when there are
variations with different prices: if at least one variation was
outside of the price range but other were inside, the product wasn't
being listed.
@Konamiman Konamiman self-assigned this Feb 5, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Feb 5, 2021

📦 Artifacts ready for download!

@Konamiman Konamiman mentioned this pull request Feb 5, 2021
7 tasks
@Konamiman Konamiman requested review from a team and jonathansadowski and removed request for a team February 5, 2021 15:53
Copy link
Contributor

@jonathansadowski jonathansadowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍 thanks!

@jonathansadowski jonathansadowski merged commit 10f92ca into master Feb 5, 2021
@jonathansadowski jonathansadowski deleted the fix/25261 branch February 5, 2021 18:19
@woocommercebot woocommercebot added release: add changelog Mark all PRs that have not had their changelog entries added. [auto] release: add testing instructions PRs that have not had testing instructions added to the wiki. [auto] labels Feb 5, 2021
@roykho roykho added this to the 5.1.0 milestone Feb 11, 2021
@zhongruige zhongruige added testing instructions added and removed release: add testing instructions PRs that have not had testing instructions added to the wiki. [auto] labels Feb 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release: add changelog Mark all PRs that have not had their changelog entries added. [auto]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Price filter excludes variations

7 participants