ElasticPressLabs icon indicating copy to clipboard operation
ElasticPressLabs copied to clipboard

Out of stock products appear in Filtered Results

Open lfinsaas opened this issue 2 years ago • 5 comments

Describe the bug

Hi folks,

Loving the tool so far (very fast!) but we're running into an issue with the filters. They do not appear to be hooking into product variations' stock status. From what I can tell, if the product has the attribute, EP will pull the product into the output — despite the Woo setting to hide out of stock items. This makes it pretty much impossible for customers to navigate the Clearance section of the site, as sizes are pretty spotty.

Any ideas? Do we need to add a filter of some sort?

Thanks!

Steps to Reproduce

  1. Go to https://jaxengrey.com/product-tag/clearance/
  2. Filter on Sizes —> Large
  3. Click on the Ponto Performance Pant (https://jaxengrey.com/product/ponto-performance-pant-chestnut-heather/)
  4. No Large in Stock!

Screenshots, screen recording, code snippet

Screenshot 2023-03-28 at 13 36 41 Screenshot 2023-03-28 at 13 36 54

Environment information

Macbook OS 13.0.1 (22A400) Chrome 111.0.5563.110

WordPress and ElasticPress information

Up to Date (can provide status again if necessary)

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

lfinsaas avatar Mar 28 '23 11:03 lfinsaas

Hi @lfinsaas,

I can confirm that it's a bug. We are going to work on the fix, and it will be available in a future release.

Regards, Burhan

burhandodhy avatar Mar 30 '23 12:03 burhandodhy

Any workarounds in the meantime?

Would implementing the method outlined in Issue 10up/ElasticPress#2473 (sorting out of stock items to the back) hook into these variable products?

lfinsaas avatar Mar 30 '23 12:03 lfinsaas

We apologize for the inconvenience. I just tested again, and everything is working as expected. When "Out of stock visibility" is enabled. WooCommerce only hides the simple product from the shop page; the Variable product remains displayed. The behavior is the same for the ElasticPress filters.

burhandodhy avatar Apr 03 '23 06:04 burhandodhy

Uh, OK?

Sure, EP aligns with standard Woo behavior — but EP extends Woo functionality, right?

Removing product variations w/o stock from the query seems like a pretty basic function that EP should be able to tackle.

Are there workarounds in the meantime?

If nothing else, can this be added to a feature roadmap?

Thank you.

lfinsaas avatar Apr 03 '23 10:04 lfinsaas

Hi @lfinsaas,

Although it may seem like a pretty basic function, it is not. The query that fetches products matches only parent products and not variations. As the variation availability is not something that belongs directly to the parent product, it is not something we could filter on.

To have that working, ElasticPress would need to:

  1. Inject in the parent product the availability of its variations and keep it updated
  2. Detect:
    • if the WooCommerce setting is turned on
    • if a Facet filter is applied to the current query
    • then filter out all parent products with variations belonging to what's been filtered that are out of stock.

Number 1 isn't easy (more a writing chore than anything) but nr. 2 is a big lift.

I'm changing this issue to enhancement now. Any Pull Requests to have that done are welcome. Thanks

felipeelia avatar Apr 20 '23 20:04 felipeelia