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

3rd Party Plugin Compatibility: WooCommerce + Hide Out of Stock Products #674

Closed
raamdev opened this issue Feb 19, 2016 · 8 comments
Closed

3rd Party Plugin Compatibility: WooCommerce + Hide Out of Stock Products #674

raamdev opened this issue Feb 19, 2016 · 8 comments
Assignees
Milestone

Comments

@raamdev
Copy link
Contributor

@raamdev raamdev commented Feb 19, 2016

A user report indicates that when "hide out of stock products from the catalog" is enabled in WooCommerce, and a product goes out of stock, the catalog pages are not updated (i.e., the old cache file is loaded, which shows the now-out-of-stock product that should be hidden).

In #597 we improved compatibility with WooCommerce and stock changes, however it sounds like there's room for more improvement here so I'm opening this GitHub issue so that we can look into this more closely.

@kristineds
Copy link

@kristineds kristineds commented Jul 25, 2016

@raamdev I'm unable to reproduce this problem with WordPress v4.5.3 + Comet Cache v160709 + WooCommerce v2.6.3 using these steps.

  • Installed, activated, enabled Comet Cache v160709
  • Installed, activated, enabled WooCommerce v2.6.3
  • Enabled Hide out of stock items from the catalog in WooCommerce > Settings >Products > Inventory
  • Created two sample products that are both in stock. Both are showing up on /shop page.
  • Changed stock status of Product#1 to out of stock
  • Went back to /shop page and Product#1 is not displayed, as expected.
  • Tried searching for Product#1, using the WooCommerce Product Search widget, and got the message No products were found matching your selection.
@jaswrks
Copy link

@jaswrks jaswrks commented Jul 26, 2016

Changed stock status of Product#1 to out of stock
Went back to /shop page and Product#1 is not displayed, as expected.

The reason for you being unable to reproduce it this way could be because you changed this from the admin, where a change in the stock status is also accompanied by the save_post action behind-the-scenes. Whereas only changing the stock status can be done by updating just a meta value, which Comet Cache does not pick up on.

I suggest fixing this by attaching to this hook in WC.
https://github.com/woothemes/woocommerce/blob/579175257f51f3ba76649bcf13ccd9688bbe5cd0/includes/class-wc-product-variable.php#L92

woocommerce_product_set_stock_status
@raamdev
Copy link
Contributor Author

@raamdev raamdev commented Jul 26, 2016

Comet Cache already attaches to woocommerce_product_set_stock, so what needs to be determined is why that's not enough, or if we need to attach to both.

@jaswrks
Copy link

@jaswrks jaswrks commented Aug 3, 2016

You'll need the *_status hook variation also, because of this WC function that makes a call only to update the stock status, not the stock count itself. https://github.com/woothemes/woocommerce/blob/1b545aa605008c92dc9e3535feb8f889ae8a31df/includes/wc-product-functions.php#L52

@raamdev
Copy link
Contributor Author

@raamdev raamdev commented Aug 3, 2016

@jaswsinc Got it. Thanks for the link to the WooCommerce source! I'll get this fixed for the next release.

@raamdev raamdev modified the milestones: Next Release, Future Release Sep 6, 2016
@raamdev raamdev removed their assignment Oct 11, 2016
jaswrks pushed a commit to wpsharks/comet-cache-pro that referenced this issue Nov 8, 2016
jaswsinc
…`woocommerce_product_set_stock_status` hook in addition to the `woocommerce_product_set_stock` hook. See also: [issue #674](wpsharks/comet-cache#674) if you'd like additional details.
@jaswrks
Copy link

@jaswrks jaswrks commented Nov 8, 2016

Next Release Changelog:

  • Bug Fix: Enhancing WooCommerce integration by listening to the woocommerce_product_set_stock_status hook in addition to the woocommerce_product_set_stock hook. See also: issue #674 if you'd like additional details.
@renzms
Copy link

@renzms renzms commented Nov 17, 2016

@raamdev

Confirmed Working

Steps taken

  • installed WooCommerce + Comet Cache v161116-RC
  • enabled hide out of stock products
  • set up free test product with stock of 1
  • Visited Shop catalog page and purchased item
  • Revisited shop page after purchase to check for out of stock item
  • Item does not appear on stock page and new cache is built

Shop Catalog with Product In Stock with 1 item

screen shot 2016-11-17 at 10 37 35 pm

After Purchase of 1 Product (Out of Stock)

screen shot 2016-11-17 at 10 39 21 pm

@raamdev
Copy link
Contributor Author

@raamdev raamdev commented Nov 19, 2016

Comet Cache v161119 has been released and includes changes from this GitHub Issue. See the v161119 announcement for further details.


This issue will now be locked to further updates. If you have something to add related to this GitHub Issue, please open a new GitHub Issue and reference this one (#674).

@raamdev raamdev closed this Nov 19, 2016
@wpsharks wpsharks locked and limited conversation to collaborators Nov 19, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants