Complete Guide: Create Save and Restore Cart Plugin for WooCommerce – Best of 2023


As WooComerce lets you create an e-commerce business (store), manage inventory, accept payments, and much more. It comes with almost all the functionalities that you require to open an online store. It helps you sell products or services online from your WordPress site at a very affordable and accessible manner.

Create a Save and Restore Cart Plugin
Create a Save and Restore Cart Plugin

Are you willing to know How to create a Save and Restore Cart plugin for WooCommerce? So we are going to define you properly on how to Create a Save and Restore Cart Plugin. In WooCommerce, the details of the cart are saved, only when a user proceeds to checkout and clicks on the ‘Place Order’ button.

As the WooCommerce checkout page provides users with predefined areas, that are placed in a particular order on the checkout page. 

These details are available on each user account, such as ‘recent orders’ if an order has been marked as ‘complete’, then the user can reorder the same item. This functionality is naturally present in WooCommerce to reorder the previously made order.

But we say that we wanted to provide a similar functionality to a user, but where the user can save a filled cart, As through the WooCommerce product table, it lets user display products in a searchable catalog. Where he can later be sent for order. 

As where product catalog is a collection of information about an individual product. Products are displayed with specific versions or various forms of an asset. Also, a WooCommerce product catalog is an individual catalog for all product of your WooCommerce store.

For example, if a user wants to save the cart’s content, then he may have an option to do this before the checkout. He could then restore the saved cart and then, proceed to checkout, whenever appropriate.

In this type of case use the following options to Create a Save and Restore Cart Plugin would have been given below:

Save Cart Option: Before checkout, a user has the option to ‘Save Cart’.

View Saved Carts: The details of the cart will be saved in the form of a list, according to the recent orders, under the user account.

Restore Cart: The user then has the option to restore the saved car to buy.

Saving Cart Details?

In order to provide an option to the user to save the current cart, there should be a button. For example, ‘Save Cart’ alongside ‘Proceed to checkout’.

However, when a user clicks on this button, the user has to save the current cart details. As according to research the normal leaving cart rate by the users is 69.23. It can also be seen in the way that every 7 out of 10 customers tend to abandon their e-store carts.

These details can be saved as a meta value for the user. The user meta is the details provided by the user which can be saved as a meta value for the user during the checkout process.

Here, we need to add a function to the ‘Save Cart’ button click, as follows:

function wdm_save_cart_details()



 global $woocommerce;

// get user details

 global $current_user;


if (is_user_logged_in())


   $user_id = $current_user->ID;

   $cart_contents = $woocommerce->cart->get_cart();

   $meta_key = ‘cart-‘.date(‘l dS F’);

   $meta_value = $cart_contents;

   update_user_meta( $user_id, $meta_key, $meta_value);



This function will save details in the form of ‘wdm_save_cart_details’ meta value for the user in the cart. Additionally, you can clear the cart, after a user selected the save cart option.


You can save the details of the car, using the same function on any suitable hook, when necessary. For example, the details of the cart are saved only when the user clicks, ‘Place order’. You can instead save cart details, every time when a user click on ‘Proceed to Checkout’.

Restore Previous Cart Content

The next step is to give a user the possibility of selecting a previously saved cart. For this, a list of saved cart should be displayed under every user account. The user can see the saved cart again, and click on the ‘Restore Cart’ option to refill his shopping cart.

Most shopping cart solutions are the default behavior to release the checkout (such as WooCommerce) before the customer continues to checkout.

Here, we will have to read saved metadata and fill the shopping cart. As where metadata is information related to the content such as date and timeauthor name, title, and more. You must provide a function, as shown below:

function wdm_restore_cart_details($wdm_selected_cart_key)




// clear current cart, in case you want to replace cart contents, else skip this step


 // add cart contents

 foreach ( $cart_content as $cart_item_key => $values )


   $id =$values[‘product_id’];


   $woocommerce->cart->add_to_cart( $id, $quant);



Remember that, to redirect the person to the checkout page, after filling the cart. To create a ‘Save and Restore Cart’ extension for the WooCommerce plugin, you can put this code in your own custom plugin easily.

Where a plugin is defined as a type of software that contains a group of functions that can be added to a WordPress website. They are used to provide additional functionality to your application.

Some of the Save and Restore Cart Plugins for WooCommerce:-

Wrapping Up

Here, through this post, you can easily create a Save and Restore cart plugin for WooCommerce store.

Read carefully and create a Save and Restore cart plugin. And this leads to the end of the blog. If you have any question and suggestion related to this, you can use the comment section. We hope this blog is useful to you!

If you are still facing problem then you also have another option of getting help from our WooCommerce Support Team. Without any wastage of your precious time, you will get the best support by our WooCommerce Experts. Dial +1-888-738-0846(Toll-Free).

Leave a Reply