Skip to content

Instantly share code, notes, and snippets.

@SeanChDavis
Created January 18, 2016 16:51
Show Gist options
  • Save SeanChDavis/d58fe22c5cd8ab4e1c0e to your computer and use it in GitHub Desktop.
Save SeanChDavis/d58fe22c5cd8ab4e1c0e to your computer and use it in GitHub Desktop.
EDD no repeat line items in cart
<?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() && defined( 'DOING_AJAX' ) ) {
die('1');
} else {
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