Skip to content

Instantly share code, notes, and snippets.

@amdrew
Last active November 11, 2019 06:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amdrew/2192eb02839fcdf9e3d2 to your computer and use it in GitHub Desktop.
Save amdrew/2192eb02839fcdf9e3d2 to your computer and use it in GitHub Desktop.
Easy Digital Downloads - Make sure only 1 download can exist in the cart
<?php
// 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:
add_filter( 'edd_pre_add_to_cart_contents', '__return_false' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment