A customer on the Easy Digital Downloads forums needed a way to limit their checkout cart to only 1 download at a time.

The following filter will clear the cart right before a download is added via the purchase buttons, meaning only the most recently added download will exist in the cart.

Copy and paste the following filter into your child theme’s functions.php or custom plugin: