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

WooCommerce: WP Rocket's "clean" functions run numerous times during checkout #2287

Open
vmanthos opened this issue Jan 29, 2020 · 10 comments
Open
Labels
3rd party compatibility Issues related to 3rd party compatibility like theme, plugin or hosting module: cache needs: product cleanup needs: testing priority: medium Issues which are important, but no one will go out of business.

Comments

@vmanthos
Copy link
Contributor

On WooCommerce sites, when:

  • items are added in the cart,
  • User Cache is enabled and
  • a "native" payment gateway is used, i.e. one that uses WooCommerce's stock update functions,

WP Rocket's rocket_clean_post() and rocket_clean_files_users() are called numerous times, proportional to the items that were added in the cart.

If those are just a few, everything is working as expected. However, when a lot of items are added in the cart, this can lead to the script timing out and the order taking a lot of time to be processed and completed.

For the rocket_clean_files_users(), we could limit it to run just once per order.

Reference: WooCommerce's functions/methods that are used to update the stock

wc_reduce_stock_levels
https://github.com/woocommerce/woocommerce/blob/7701d4b57cb20dc89e25bb7bf2ff872d85f4c535/includes/wc-stock-functions.php#L139-L196

wc_update_product_stock
https://github.com/woocommerce/woocommerce/blob/7701d4b57cb20dc89e25bb7bf2ff872d85f4c535/includes/wc-stock-functions.php#L42

update
https://github.com/woocommerce/woocommerce/blob/7701d4b57cb20dc89e25bb7bf2ff872d85f4c535/includes/data-stores/abstract-wc-order-item-type-data-store.php#L63-L92

save
https://github.com/woocommerce/woocommerce/blob/7701d4b57cb20dc89e25bb7bf2ff872d85f4c535/includes/wc-stock-functions.php#L50

Cache clearing takes place here:
https://github.com/woocommerce/woocommerce/blob/dc5712db84b45fa215c5096cf55e669292e89383/includes/abstracts/abstract-wc-product.php#L1354-L1394


Related ticket:
https://secure.helpscout.net/conversation/1064404566/142633/

@camilamadronero-zz
Copy link

@svaldesm
Copy link

I'm the guy who reported the issue by Camila.
Happy to help test and see if there's a solution. I love WP Rocket but our best customers, the ones who make big orders, have an awful experience because of this.
Thanks for your help!

@vmanthos
Copy link
Contributor Author

Another ticket:
https://secure.helpscout.net/conversation/1090990969/147529/

As a possible solution, we could disable the automatic cache clearing/preloading until after an order has been processed.

We would need to store the IDs of the products for which we need to clear cache/preload.

@GeekPress GeekPress added priority: medium Issues which are important, but no one will go out of business. 3rd party compatibility Issues related to 3rd party compatibility like theme, plugin or hosting labels Feb 27, 2020
@naratt
Copy link

naratt commented Sep 19, 2020

Any update ?
What i found on my website is that checkout is vary slow (30+sec) if the products belongs to multiple categories.

@sandyfigueroa
Copy link
Contributor

This case has the same issue when a product belongs to multiple categories: https://secure.helpscout.net/conversation/1275188620/192678/

@jazir555
Copy link

jazir555 commented Feb 2, 2021

Any update?

@GeekPress
Copy link
Contributor

Any update?

If we don't comment on the issue, it means there is no update. Please note we have 445 opened tickets, and we need to prioritize...

@NataliaDrause
Copy link
Contributor

@NataliaDrause
Copy link
Contributor

@NataliaDrause
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3rd party compatibility Issues related to 3rd party compatibility like theme, plugin or hosting module: cache needs: product cleanup needs: testing priority: medium Issues which are important, but no one will go out of business.
Projects
None yet
Development

No branches or pull requests

10 participants