woocommerce / woocommerce

A customizable, open-source ecommerce platform built on WordPress. Build any commerce solution you can imagine.
https://woocommerce.com
9.41k stars 10.76k forks source link

If the cache is enabled, the "Recently viewed" query will not work properly. #31850

Open 79ho3ein opened 2 years ago

79ho3ein commented 2 years ago

Prerequisites

Describe the bug

If you remember, I previously posted a report that this query interferes with the wp-rocket plugin. I even discussed this with the wp-rocket writers and they said it was not our problem and we could not help it. They were right. The problem is that the "Recently viewed" query supports cache. Because of this, this query never worked properly. Cache support by this query causes it to add products to the list by mistake. In general, the cache corrupts this query. Please correct this. So that this query is automatically removed from the cache. In this case, it will no longer be a problem. (I disabled the cache on the page I was using this query and found that the problem was with the cache)

thank you

Expected behavior

Activating the cache should not interfere with the operation of this query.

Actual behavior

-

Steps to reproduce

1- Install the jet woobuilder and wp-rocket plugins at the same time. 2- On a page (for example, the main page), add the product grid widget and set its query to Recently viewed. 3- To test, visit different products and finally see the list of products you have seen before. It does not work properly. 4- Now edit the page (home page) and disable its cache. https://prnt.sc/26pd5qz 5- Visit different products again and see the list of recently visited products again. It will work properly.

WordPress Environment

-

Isolating the problem

woocommercebot commented 2 years ago

Hi @79ho3ein,

Thank you for opening the issue! It requires further feedback from the WooCommerce Core team.

We are adding the needs developer feedback label to this issue so that the Core team could take a look.

Please note it may take a few days for them to get to this issue. Thank you for your patience.

79ho3ein commented 2 years ago

thank you @ObliviousHarmony I am using the jet woobuilder plugin. In this plugin, it is possible to display recently visited products. But unfortunately there is a problem that I described above. I talked to jet woobuilder developers and they said the problem should be solved by WooCommerce. Because we follow WooCommerce. So I have this request from you. Just remove the cache support for "Recently Visited Products" To solve the problem.

thank you

peterfabian commented 2 years ago

Hi, WooCommerce stores the recently viewed products in a cookie, so if you cache it, it won't indeed work properly. I'm marking this as a potential enhancement with low priority.

Side note: we need to check the lifecycle of the cookie, as it seems it doesn't get cleared when the session gets cleared.

an0o0nym commented 1 year ago

This plugin saved me lots of time https://github.com/pinoceniccola/woocommerce-recently-viewed-ajax ! It just works. ™

I am using Super Page Cache for Cloudflare but I don't think it matters in this case.