# "Empty Cart" Button on the EDD Checkout

> Adds an "Empty cart" button below the Easy Digital Downloads checkout cart so buyers can start again in one click.

- Type: PHP
- Runs: Run everywhere
- Category: [Easy Digital Downloads](https://wpide.com/library/category/edd/)
- Requires: Easy Digital Downloads
- Tags: edd, cart, checkout, buttons
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/edd-empty-cart-button/

## Code

```php
add_action( 'edd_cart_footer_buttons', function () {
    printf(
        '<a class="edd-submit button wpide-edd-empty-cart" href="%1$s" onclick="return confirm(%2$s)">%3$s</a>',
        esc_url( wp_nonce_url( add_query_arg( 'edd_action', 'wpide_empty_cart', edd_get_checkout_uri() ), 'wpide_edd_empty_cart' ) ),
        esc_attr( wp_json_encode( 'Remove all items from your cart?' ) ),
        esc_html( 'Empty cart' )
    );
} );

add_action( 'edd_wpide_empty_cart', function () {
    if ( isset( $_GET['_wpnonce'] ) && wp_verify_nonce( sanitize_key( $_GET['_wpnonce'] ), 'wpide_edd_empty_cart' ) ) {
        edd_empty_cart();
    }

    wp_safe_redirect( edd_get_checkout_uri() );
    exit;
} );
```

## Notes

Asks for confirmation first and uses a security token, so the link cannot be triggered from other sites.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find ""Empty Cart" Button on the EDD Checkout" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
