# EDD Cart Link With Item Count Shortcode

> Adds a [wpide_edd_cart] shortcode that prints a "Cart (2)" link to the Easy Digital Downloads checkout, for headers, menus or widgets.

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

## Code

```php
add_shortcode( 'wpide_edd_cart', function ( $atts ) {
    if ( ! function_exists( 'edd_get_cart_quantity' ) ) {
        return '';
    }

    $atts  = shortcode_atts( array( 'label' => 'Cart' ), $atts, 'wpide_edd_cart' );
    $count = (int) edd_get_cart_quantity();

    return sprintf(
        '<a class="wpide-edd-cart-link" href="%1$s">%2$s <span class="edd-cart-quantity">(%3$d)</span><span class="screen-reader-text"> %4$s</span></a>',
        esc_url( edd_get_checkout_uri() ),
        esc_html( $atts['label'] ),
        $count,
        esc_html( sprintf( _n( '%d item', '%d items', $count ), $count ) )
    );
} );
```

## Notes

Use [wpide_edd_cart label="Basket"] to change the text; full-page caches may need to skip pages that show it.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "EDD Cart Link With Item Count Shortcode" 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/
