Created
August 31, 2017 19:28
-
-
Save SeanChDavis/cd95ca373bb0c7b55ca07853f19dbb81 to your computer and use it in GitHub Desktop.
Revisions
-
Sean Davis created this gist
Aug 31, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ <?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 );