Search
Close this search box.
Search

WooCommerce Multisite: The Global Cart

Listen to this article
MultiSite Shopping Cart WooCommerce
Single Shopping Cart Across WooCommerce Multisite

This article explains the implementation details of the WooCommerce Global Cart feature. To understand the concept of the Global Cart, kindly read: How to Create a Single Shopping Cart and Checkout Option for WooCommerce Multi-Site Stores, before reading this article.

There has been a lot of debate on how the WooCommerce global cart would work, in a multisite setup. For that matter, it seems like some of the features could be provided only by customizing the core functionality. But let’s not have it come to that. The solution that we will try to provide, would allow us to work with what we have. Since WooCommerce provides many hooks and filters, we expect that a solution is possible even though it might be complicated. We want to make this clear, that do not have a solution in place. But we have investigated the requirements in detail and have come up with an postulated solution.

[space]

WooCommerce Global Cart

The WooCommerce Global Cart is a single shopping cart across all stores in a multisite. This means, the cart details have to be persistent across all stores. Since each store has its own sub-domain, we cannot use sessions to save cart data. The option we have, is to either save the data in the database, or use network level cookies. The better option is to save the cart as part of the database (as user meta). WooCommerce handles the ‘Persistent Cart’ in the same way.

Every time a user visits a site, and adds an item to the cart, the item will be added to the global cart in user’s meta as well. Of course this is only possible if the user is logged-in. Thus there will have to be a condition that a user has to log in, when adding an item to the cart (or when he visits a store). If the user is not logged in, a persistent cart cannot be maintained.

The cart details will be maintained as follows:

user meta > global_cart > store1> item abc,item xyz
store2> item hjk

Since the user is the same across all sites in the network, the user meta will be the same. Thus the cart can grow as and when user adds an item to the cart, in a particular store. The ‘View Cart’ button, will show the global cart details in the Cart Page.

The Cart Page

The Cart Page will be created on the main site. On this page, the data present in user meta will be read and a cart-like display will be created. The page will be similar to the usual Cart Page in WooCommerce, but the product information will be linked to products from individual sites. On this page, there are several cart related operations which can be usually performed.

Remove or Update Cart Items

If a cart item is removed, then it will be removed from user meta(i.e., the global cart) as well. But, if the quantity of an item is updated (increased), then first the product inventory will be checked (by switching to the relevant store), and then (upon verification), the user meta will be updated.

Coupons and Shipping

When it comes to applying coupons and shipping rates, the process becomes complicated. Here, you have the following options:

  1. Coupon Codes: Product discount coupons can be created for individual stores as usual. But if a cart discount coupon is created, it should be created across all stores with the same code and value. This will ensure, that when a user applies a cart discount coupon, all items in the cart will be discounted with the same value.
  2. Shipping Rates: The Shipping methods and rates should be the same across all stores. The rates applied for each shipping method might be different, but same shipping methods (Flat Rate, International, Free Shipping, etc)  should be made available. This is because, there is only a single option to select the shipping method for all stores.

[space]

WooCommerce Multisite Checkout

After the shipping costs are updated, the next step is checkout. On the Checkout Page, the address information will be auto-filled (or accepted) as usual. The checkout page will also be a page on the main site (like the cart page), and as far as the look is concerned, it will be same as the usual WooCommerce checkout page. On this page, the user can decide to change the shipping method, before proceeding to order creation. The change in shipping method should be handled by querying for the shipping cost, and updating the total cost.

Creating an Order

When a user clicks on the ‘Place Order’ button, individual orders should be created for each store. The coupon information, shipping details, and address information, should be sent with each order. This can be done by switching to a single store and accessing the WooCommerce > Cart, for that particular store. Using the cart information, we can create an order for the store. We will have to integrate a payment gateway in the main site, to allow payments for orders. The transaction notifications (such as Payment Pending, Payment Complete, Cancelled, etc) should be sent to each store, as applicable.

[space]

Conclusion

The Global Cart feature provides better user experience, and helps improve sales when your products are distributed across several WooCommerce stores on WordPress multisite. The implementation is however effort intensive, because WooCommerce as such does not provide support for this. However, since WooCommerce is highly customizable owing to the plugin architecture, and extension support, we can provide such a solution if required.

 

Pooja Mistry

Pooja Mistry

6 Responses

  1. Dear WisdmLabs,

    do you have any update on this?
    Maybe you have an “unofficial” plugin which you want to share?
    Many thanks in advance.

Leave a Reply

Your email address will not be published. Required fields are marked *

Get The Latest Updates

Subscribe to our Newsletter

A key to unlock the world of open-source. We promise not to spam your inbox.

Suggested Reads

WordPress Development

Custom WordPress Solutions, for You

LearnDash Development

Custom LearnDash Solutions, for You

WooCommerce Development

Custom WooCommerce Solutions, for You

WordPress Plugins

Scale your WordPress Business

WooCommerce Plugins

Scale your WooCommerce Business

LearnDash Plugins

Scale your LearnDash Business

Label

Title

Subtext

Label

Title

Subtext

Join our 55,000+ Subscribers

    The Wisdm Digest delivers all the latest news, and resources from the world of open-source businesses to your inbox.

    Suggested Reads