rhubarbgroup / redis-cache

A persistent object cache backend for WordPress powered by Redis. Supports Predis, PhpRedis, Relay, replication, sentinels, clustering and WP-CLI.
https://wordpress.org/plugins/redis-cache/
GNU General Public License v3.0
427 stars 149 forks source link

Getting cached WooCommerce Order object in custom ajax request #448

Closed xlplugins closed 1 year ago

xlplugins commented 1 year ago

Hi there,

We are the developers of Stripe Payment Gateway for WooCommerce and one of our client faced an issue during the WooCommerce checkout and after troubleshooting the issue we found out its related to object caching done by object cache PRO plugin.

So the issue is we are not getting the desired meta data from the WooCommerce order object while at the exact same time when we query get_post_meta() method we get the desired results. As soon as we disable Object cache PRO the issue resolves.

Here is the sample key value pair of the meta that we are fetching. _fkwcs_setup_intent : a:2:{s:2:"id";s:29:"seti_1MtUw7KfFXJnFEHA0UaWRTqA";s:13:"client_secret";s:68:"seti_1MtUw7KfFXJnFEHA0UaWRTqA_secret_NeoZqeKuG2VSmeWVAMlLPwHAiWThPbN";}

When we use $order = wc_get_order($order_id); $intent = $order->get_meta( '_fkwcs_intent_id' );

we get empty value.

we have also explained the issue in detail here : https://www.loom.com/share/79a8dc7262f643b686567b34903d72a4

We are looking for a solution to make it work with Object Cache PRO plugin. Please check and let us know.

Thanks!

tillkruss commented 1 year ago

@xlplugins: Can you please send me a snippet of wp_cache_set() and wp_cache_get() that replicates your buggy behavior?

xlplugins commented 1 year ago

Hi @tillkruss , Not exactly sure what you want us to send further, could you please elaborate a little about that?

Also we do not use wp_cache_set() and wp_cache_get() in our plugins code, while WooCommerce does use this method in their abstract class WC_Data::read_meta_data() method. Here https://plugins.trac.wordpress.org/browser/woocommerce/trunk/includes/abstracts/abstract-wc-data.php#L618

Here we are just calling woocommerce native method which is wc_get_order() and WC_Order::get_meta() and no other code which could impact the returned data. So this issue is most likely causing other plugins too which are using woocommerce along with Object Cache PRO.

It seems the conflict is not between Stripe gateway and object cache pro but between Object cache pro and WooCommerce.

Thanks

tillkruss commented 1 year ago

Can you give me a code snippet of writing and reading using WC_Data that re-creates your issue? Including the exact data you pass into it?

tillkruss commented 1 year ago

Let's get this sorted. Can you provide me with a snippet that replicates how you store data?

tillkruss commented 1 year ago

@xlplugins I'm happy to help you with your code and investigate the issue, BUT I need more information from you.