Hi @butchewing,
Welcome to the WooCommerce Stripe Gateway forum. Thank you for sharing the detailed error log. I can understand how frustrating it must be to encounter a critical error when attempting to process a refund, especially when everything else appears to be functioning properly.
The error message, Uncaught Error: Call to a member function get_items() on int, suggests that a numeric order ID (an integer) was passed to a method expecting a WC_Order object. This typically occurs when custom code or a plugin interacts with the refund process but fails to properly initialize the order object before calling $order->get_items().
To help narrow this down, please try the following steps:
- Update your WooCommerce database by going to WooCommerce → Status → Tools and clicking Update database if a prompt is shown. A mismatch between your WooCommerce plugin version (9.8.5) and database version (9.8.4) could be contributing to the issue.
- Temporarily switch to a default theme like Twenty Twenty-Four and deactivate all plugins except for WooCommerce and WooCommerce Stripe Gateway.
- Try issuing the refund again and see if the error still occurs.
If the issue is resolved after these steps, you can reactivate your plugins one by one to pinpoint the one causing the conflict.
Also, if you’ve recently added or updated any customizations, it’d be worth reviewing those sections closely for functions that might be misusing WC_Order data.
If the problem persists or you’re unable to find the cause, please share your System Status Report with us so we can review your site configuration more closely. You’ll find it under WooCommerce → Status → Get system report → Copy for support, then paste it into https://pastebin.com or https://quickforget.com and share the link here.
We’ll be glad to take a closer look once we have that!
Hi @butchewing, did you found any solution for this. I am having the same issue.
Hi @nayembwip,
Thank you for reaching out and letting us know you’re facing a similar problem. To help you better, please open a new support topic and include as many details as possible about the issue, such as screenshots or screen recordings if needed. We’ll be glad to assist you.
@butchewing, it’s been nearly a week since we last heard from you. Just following up to see if your issue has been resolved or if you have any updates to share.
Sorry, nothing resolved on my end yet. It is still happening when a refund is generated. I plan to move to staging and deactivate all plugins and go through them one by one. I’m not in a big hurry as there are WAY too many plugins on this site. I was kind of hoping that a resolution would come before I had to actually go through that exercise. But, now that @nayembwip is also having the issue, I have more of an impetus to do it.
Hi @butchewing,
Thank you for the update. No rush on the test — take your time. I also hope @nayembwip has created a topic so we can compare both of your setups to identify any common plugin.
Whenever you finish the test, feel free to share your findings here.
You’re not going to believe this. I’m 99.99% sure that the issue is Object Cache. When disabled, refunds do not generate errors. When enabled, refunds throw an error. With that being the case, is this something that needs to be corrected in the Stripe plugin itself?
When WooCommerce calls get_qty_refunded_for_item(), it expects each refund returned by get_refunds() to be a WC_Order_Refund object (or at least an object with a get_items() method). However, because of Object Cache Pro, the cached refunds data is sometimes an int (or null), not an object. This leads to a fatal error when the code directly calls get_items() on what turns out to be an int.
Here’s a more technical breakdown:
- The WC_Order::get_refunds() method uses wp_cache_get() to attempt to retrieve a cached refunds array. Object Cache Pro is used to speed up repeated queries.
- If the cache returns data in an unexpected format (for example an integer or incomplete data structure), then iterating over that data results in a variable that isn’t a WC_Order_Refund.
- The method get_qty_refunded_for_item() iterates over what it assumes are refund objects:
- It calls get_items() on each refund.
- If the refund isn’t an object (because of cache corruption or misformatting), PHP throws a fatal error when trying to call a method on a non-object (an int).
- The underlying issue appears to be that Object Cache Pro isn’t returning data in the expected format—possibly due to caching an int (like an ID placeholder or an error code) instead of a full refund object.
- A temporary workaround is to add a defensive check (using is_object() and method_exists()) before calling get_items(), which avoids the fatal error by skipping any refund that isn’t in the proper object format. However, the root cause is in the caching layer, so a long-term solution should address how Object Cache Pro caches or retrieves this data.
This explanation highlights why the error occurs and how the caching plugin’s behavior disrupts the expected data structure for WooCommerce refunds.
-
This reply was modified 10 months, 2 weeks ago by
butchewing.
Hi @butchewing,
Thank you so much for your thorough breakdown of the issue, that was incredibly insightful and helpful. You’ve pinpointed the root cause with impressive clarity, especially how Object Cache Pro appears to interfere with the expected data structure for refunds.
Just to confirm, are you indeed using the Object Cache Pro plugin directly, or is it being implemented via your host or server-side caching layer? If it’s the plugin, then the best next step would be to reach out to the developers of Object Cache Pro so they can review how their caching logic is handling refund objects, especially in the context of WooCommerce and the WooCommerce Stripe Gateway.
Since WooCommerce expects get_refunds() to always return proper WC_Order_Refund objects, caching anything else like raw IDs or partial data structures could lead to exactly the kind of fatal errors you’re seeing. While a defensive check might be a helpful short-term patch, this is definitely something the plugin developers should be made aware of to ensure compatibility long-term.
Let us know what you hear back from them.
Hi @butchewing, thanks for the hint. It resolves my issue as well.
Hi @nayembwip,
I’m really glad to hear that the hint shared earlier by @butchewing helped resolve the issue for you as well. It’s always encouraging to see knowledge shared in the community make a difference!
If the WooCommerce Stripe plugin has been helpful for your store and you’ve appreciated the support here, we’d be grateful if you could take a moment to leave us a quick review: https://wordpress.org/support/plugin/woocommerce-gateway-stripe/reviews/#new-post
Your feedback goes a long way in helping us improve and support more users effectively. Thank you again!
I have added a possible fix by removing woocommerce_refunds and wc_order_refunds from the cache groups in Object cache pro.
https://objectcache.pro/docs/ignoring-groups
'non_persistent_groups' => [
'woocommerce_refunds',
'woocommerce_orders',
'woocommerce_order_items',
'woocommerce_order_data',
'wc_order_meta',
'wc_order_refunds',
'woocommerce',
'wc_refund',
],
Hi @butchewing,
Thanks for the update! That’s a very helpful workaround, and excluding those cache groups from Object Cache Pro sounds like a practical step to prevent the plugin from returning incomplete refund data. This should help others facing similar issues as well.
Appreciate you taking the time to share your findings!