=== SPP Empty Cart Button for WooCommerce ===
Contributors: spp
Tags: woocommerce, cart, empty cart, ecommerce, shopping cart
Requires at least: 6.0
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Add a simple "Empty cart" button to the WooCommerce classic cart page and Cart block so customers can clear all items with one click.

== Description ==

SPP Empty Cart Button for WooCommerce improves the baseline checkout experience by giving shoppers a fast way to remove every product from their cart without deleting items one by one.

The plugin supports both the classic WooCommerce cart template and the WooCommerce Cart block. On classic carts, the button uses the standard cart form nonce for secure processing. On block carts, the button uses a secure AJAX request. In both cases, the cart is cleared with `WC()->cart->empty_cart( true )` and a success notice is displayed.

= Features =

* One-click empty cart button for classic cart templates and the Cart block
* Admin setting to choose the button location for each cart type
* Secure request handling with WooCommerce cart nonce and AJAX nonce checks
* Localized button text and notices
* Optional confirmation prompt before clearing the cart
* Lightweight code with a simple WooCommerce settings screen
* Compatible with WooCommerce HPOS and cart/checkout blocks declarations

= Filters for developers =

* `spp_empty_cart_button_text` — Change the button label.
* `spp_empty_cart_button_classes` — Change the button CSS classes.
* `spp_empty_cart_button_confirm_message` — Change or disable the confirmation prompt. Return an empty string to disable it.
* `spp_empty_cart_button_success_message` — Change the success notice after the cart is emptied.
* `spp_empty_cart_button_before_empty_cart` — Action fired before the cart is cleared.
* `spp_empty_cart_button_after_empty_cart` — Action fired after the cart is cleared.

== Installation ==

1. Upload the plugin files to the `/wp-content/plugins/spp-empty-cart-button-for-woocommerce` directory, or install the plugin through the WordPress plugins screen.
2. Activate the plugin through the **Plugins** screen in WordPress.
3. Make sure WooCommerce is installed and active.
4. Optional: open **WooCommerce > Empty Cart Button** to customize the button label and choose where the button appears.
5. Visit your cart page with items in the cart to see the **Empty cart** button.

== Frequently Asked Questions ==

= Does this plugin work without WooCommerce? =

No. WooCommerce must be installed and active.

= Where does the button appear? =

By default, the button appears in the cart actions area on the classic cart page and near the Proceed to checkout button in the Cart block. You can change both locations in **WooCommerce > Empty Cart Button**.

= Does this work with the WooCommerce Cart block? =

Yes. You have two options:

1. Add the **SPP Empty Cart** block from the block inserter (search for "SPP Empty Cart" under WooCommerce).
2. Use the WooCommerce **Cart** block and let the plugin inject the button automatically based on your location setting in **WooCommerce > Empty Cart Button**.

= How is the SPP Empty Cart block used? =

Edit your cart page in the block editor, click the block inserter (+), search for **SPP Empty Cart**, and insert the block where you want the button to appear. When the cart contains products, visitors see an Empty cart button. Clicking it clears all cart items and shows a success notice.

= Can I change the button text? =

Yes. Go to **WooCommerce > Empty Cart Button** and enter your custom text in the **Button text** field. You can also use the `spp_empty_cart_button_text` filter in code.

= Can I change the button style? =

Yes. Go to **WooCommerce > Empty Cart Button** and choose a style under **Button Style**. Available styles include Secondary, Primary, Outline, and Danger.

= Can I disable the confirmation popup? =

Yes. Use the `spp_empty_cart_button_confirm_message` filter and return an empty string.

== Screenshots ==

1. Empty cart button displayed on the WooCommerce cart page.

== Changelog ==

= 1.0.0 =
* Initial release.

== Upgrade Notice ==

= 1.0.0 =
Initial release.
