Black Friday & Cyber Monday SUPER SALE ALL WEEK:
Grab 40% OFF on plugins

Important bug fix in WooCommerce 3.1 for WordPress multisite

Recently WooCommerce has released v3.1, it was not a major update. But has some good new features and enhancements along with bug fixes. This version has had over 1600 commits from 84 contributors.

One of the major change is that now WooCommerce persistent carts are compatible with the WordPress multisite.

Yes, you read it correctly, the WooCommerce persistent carts were not compatible with the WordPress multisite. So, if you have a multisite and one of your customer had complained about the missing cart or unwanted carts then its WooCommerce persistent cart which was causing the issue on your site. It will be replicated when your subdomain at least one product share the same ID.

What was the issue?

Let’s look at the code before v3.1

Above function is executed each time when the user updates the cart on your store and it will store the customer’s updated cart information. It is storing the user’s cart details in the user_meta table, it does not store any subdomain id for that user’s cart.

Now, consider the following setup of the WordPress multisite.

  1. A multisite setup: (Network Site) (Site One, WooCommerce activated) (Site Two, WooCommerce activated) (Site Three, WooCommerce activated)
  2. Create some products in SITE One ( and SITE Third (, but we need to make sure at least one product share the same ID on each site.
  3. Open a browser and login to the network ( ). And add a product with an overlapping ID in your cart on Site One (
  4. Open another browser and login to the network ( ). Now browse to SITE Third ( and now you find a product in your Cart which you had added for site First.

Here, it’s important that user which you are logged in do not have any cart information or any session, let’s say login to the site for the first time. If loggedin user had any history of the cart then it would restore the cart from that session instead of the user meta.

So, here when I logged into the Third site it will load the cart with the cart details which was added at the site One. Here, take a note that I have not yet added the product to the cart in site Third, I just went to the cart page.

As the new user does not have any session of the carts then the WooCommerce will load the data from the user_meta. Check the below code snippet.

Subdomain site one
Subdomain site one


Subdomain site three
Subdomain site three

To overcome the issue of the cart which is not created by the customer on the WordPress multisite, WooCommmerce has now added the blog id for the persistent cart.

Now, persistent cart in the v3.1 is stored as below.

Now they have blog_id for storing the user cart. Now, each stored persistent cart have the blog id.

One of our plugins Abandoned cart need to store the loggedin users latest cart information, so we have used the WooCommecerce persistent cart. After WooCommerce 3.1 our plugin was not storing the latest cart information of the loggedin users.

get_user_meta( $user_id, ‘_woocommerce_persistent_cart_’ . get_current_blog_id(), true );

To overcome the issue we have used above code to retrieve the persistent cart of the logged in users.

If you are a developer and you have used the WooCommecerce persistent cart then you must change your code and use the blog id for retrieving the persistent cart

If you want to check the discussion on the issue then you can check here.

Browse more in: Code Snippets, WooCommerce

Share It:

Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x