Skip to content

Instantly share code, notes, and snippets.

@SeanTOSCD
Created August 31, 2017 19:28
Show Gist options
  • Save SeanTOSCD/cd95ca373bb0c7b55ca07853f19dbb81 to your computer and use it in GitHub Desktop.
Save SeanTOSCD/cd95ca373bb0c7b55ca07853f19dbb81 to your computer and use it in GitHub Desktop.
EDD prevent duplicate cart items
<?php // DO NOT COPY THIS LINE
/**
* Prevents items from being added to the cart multiple times
*
*/
function pw_edd_prevent_duplicate_cart_items( $download_id, $options ) {
if( edd_item_in_cart( $download_id, $options ) ) {
if( edd_is_ajax_enabled() ) {
wp_redirect( edd_get_checkout_uri() ); exit;
}
}
}
add_action( 'edd_pre_add_to_cart', 'pw_edd_prevent_duplicate_cart_items', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment