Title: WC()-&gt;cart-&gt;get_cart() function returns empty array
Last modified: September 24, 2024

---

# WC()->cart->get_cart() function returns empty array

 *  Resolved [SandyRig](https://wordpress.org/support/users/sandyrig/)
 * (@sandyrig)
 * [1 year, 8 months ago](https://wordpress.org/support/topic/wc-cart-get_cart-function-returns-empty-array/)
 * I have a feature on site that checks cart items and recommend related products
   but the feature stops working when **Evercache for Woo Commerce** is turned on
   in **WPEngine**. I have investigated and it turns out that this function** get_cart()**
   returns empty array for some reason after turning on **Evercache**.

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [Stef](https://wordpress.org/support/users/serafinnyc/)
 * (@serafinnyc)
 * [1 year, 8 months ago](https://wordpress.org/support/topic/wc-cart-get_cart-function-returns-empty-array/#post-18033559)
 * [@sandyrig](https://wordpress.org/support/users/sandyrig/) I would reach out 
   to WPE and ask if there’s a setting in their EverCache to prevent it being applied
   to get_cart. There pretty good about helping out. As for adding any type of override
   they’re not.
 * Just to let you know also this forum is for WooCommerce core issues. We do not
   support any 3rd party plugins or customization. If they can’t help you, you may
   want to find a developer, assuming you’re not a developer.
 *  Plugin Support [Shameem – a11n](https://wordpress.org/support/users/shameemreza/)
 * (@shameemreza)
 * [1 year, 8 months ago](https://wordpress.org/support/topic/wc-cart-get_cart-function-returns-empty-array/#post-18035329)
 * Hi [@sandyrig](https://wordpress.org/support/users/sandyrig/)
 * This could be due to how Evercache handles sessions and cookies, which are crucial
   for the `get_cart()` function to work properly. Evercache is designed to speed
   up your website by caching content, but this might interfere with dynamic features
   like your cart.
 * As a first troubleshooting step, you might need to exclude the cart and checkout
   pages from being cached by Evercache. This can usually be done from the settings
   of your caching plugin or from the WPEngine dashboard.
 * If this doesn’t resolve your issue, you may need to contact WPEngine support 
   for further assistance. They would be better equipped to handle issues specifically
   related to their platform and plugins.
 * I hope this helps! If you have any other questions, feel free to ask.
 *  Thread Starter [SandyRig](https://wordpress.org/support/users/sandyrig/)
 * (@sandyrig)
 * [1 year, 8 months ago](https://wordpress.org/support/topic/wc-cart-get_cart-function-returns-empty-array/#post-18035677)
 * I contacted WPEngine. They were clueless. We spent 2 hours and 2 different agents
   but they didn’t know what was going on. We tried excluding the cart and it didn’t
   help as well.
 * They said this function is being cached. I asked if it’s being cached why is 
   it not showing cached data and they had no idea. They suggested turning off the
   cache. How is that a solution.
 * It’s not making any sense why a core function of woocommerce stops working/returning
   data when the cache is turned on.
 *  Plugin Support [Shameem – a11n](https://wordpress.org/support/users/shameemreza/)
 * (@shameemreza)
 * [1 year, 8 months ago](https://wordpress.org/support/topic/wc-cart-get_cart-function-returns-empty-array/#post-18038035)
 * Hi [@sandyrig](https://wordpress.org/support/users/sandyrig/)
 * Caching can indeed cause issues with dynamic functions like `get_cart()`, as 
   caching essentially saves a static version of the site to improve load times,
   which can interfere with real-time updates.
 * However, it’s unusual that excluding the cart from the cache didn’t resolve the
   issue. It’s possible that other dynamic parts of your site are being affected
   by the cache as well.
 * As a next step, I would recommend trying to exclude all pages that use the `get_cart()`
   function from being cached. If that doesn’t work, you might need to consider 
   using a different caching solution that offers more granular control over what
   gets cached.
 * I understand that turning off the cache doesn’t seem like a viable solution, 
   but it might be worth temporarily trying it to see if it resolves the issue. 
   This could help confirm if the problem is indeed related to the cache.
 * I wish I could help more, but hopefully, this gets you going in the right direction
   to get the job done.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘WC()->cart->get_cart() function returns empty array’ is closed to new
replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

## Tags

 * [cache](https://wordpress.org/support/topic-tag/cache/)
 * [wpengine](https://wordpress.org/support/topic-tag/wpengine/)

 * 4 replies
 * 3 participants
 * Last reply from: [Shameem – a11n](https://wordpress.org/support/users/shameemreza/)
 * Last activity: [1 year, 8 months ago](https://wordpress.org/support/topic/wc-cart-get_cart-function-returns-empty-array/#post-18038035)
 * Status: resolved