How to Add One-Click Clear Cart Button in WooCommerce

One Click Clear Cart Button for WooCommerce

For a smooth checkout experience in your WooCommerce store, offering a “Clear Cart” button is essential. This allows customers to easily remove all items at once, saving them time and frustration.

Why You Need the Clear Cart Button for WooCommerce

While browsing your store, customers may add items to their cart for various reasons. They might be considering multiple options, saving products for later purchase, or simply changing their minds. Without a clear way to remove unwanted items, they’re forced to delete them one by one, leading to frustration and potentially abandoning their cart altogether.

Here’s why a “Clear Cart” button is essential for your WooCommerce store:

  • Enhanced User Experience: Providing a single-click solution for clearing the cart empowers customers and streamlines their shopping journey. They can effortlessly refine their selections or start fresh with a clean slate, fostering a sense of control and reducing checkout friction.
  • Reduced Cart Abandonment: Imagine a customer who accidentally adds an item or realizes they don’t need everything in their cart. A cumbersome removal process can discourage them from completing their purchase. A clear “Clear Cart” button eliminates this hurdle, encouraging them to continue the checkout process with confidence.
  • Increased Sales Conversions: By simplifying cart management, you remove a potential barrier to purchase. This can lead to higher conversion rates, as customers are more likely to finalize their orders without encountering roadblocks.

In this blog, I will guide you through two methods to add a Clear Cart button easily in to your WooCommerce.

Method 1: Using a Code Snippet

Method 2: Using a Free WooCommerce Clear Cart Button Plugin

Let’s discuss these two methods in details

Method 1: Using a Code Snippet

This method involves adding a code snippet to your theme’s functions.php file. It’s recommended to use a child theme to avoid affecting your main theme’s files. Here’s how:

  • Access functions.php: Go to Appearance > Theme File Editor. Locate your child theme’s functions.php file on the right sidebar. Alternatively, access it directly from your theme’s directory.
  • Insert the Code Snippet: Add the provided code snippet to the functions.php file.

For an easier option, you can install and activate the Code Snippets plugin. Then, add the code as a new snippet via the plugin interface.

function ts_empty_woocommerce_cart() {
if (is_checkout()) return;
WC()->cart->empty_cart();
}
add_action('wp_loaded', 'custom_empty_woocommerce_cart');

When a product is added to the cart, WooCommerce triggers various actions and filters as part of its normal process. The provided code hooks into wp_loaded, executing the ts_empty_woocommerce_cart function on every page load after WordPress has loaded

Method 2: Using a Free WooCommerce Clear Cart Button Plugin

The Clear Cart Button for WooCommerce offers a simple yet effective solution to this need, allowing customers to clear their cart with a single click.

The installation and configuration of the WooCommerce Clear Cart Button is quick and easy. Here’s how you can enable this feature on your store:

Step 1: Install the Plugin

Download and install the WooCommerce Clear Cart Button Free plugin from the WooCommerce plugin repository or your preferred plugin source.

Step 2: Enable the Plugin from the Backend

Once installed, navigate to the plugin settings in your WooCommerce backend. Enable the ‘Truncate Cart’ function to activate the plugin.

Enable the WooCommerce Clear Cart Button Plugin from the Backend

Step 3: Create the Empty Cart Button

With the plugin enabled, you can create an ‘Empty Cart’ button on your cart page with a single click. This button will be visible to customers, allowing them to clear their cart effortlessly.

Create the Empty Cart Button WooCommerce

Final Words

A “Clear Cart” button is a small yet impactful addition to your WooCommerce store. It empowers customers, reduces cart abandonment, and ultimately increases sales conversions. Both methods are easy but you can consider implementing the Free WooCommerce Clear Cart Button Plugin that provides a simple and efficient way to manage cart contents, this plugin ensures that your customers enjoy a smooth and hassle-free shopping journey.

Share this Article

Facebook
Twitter
LinkedIn