Created
August 31, 2017 19:28
-
-
Save SeanTOSCD/cd95ca373bb0c7b55ca07853f19dbb81 to your computer and use it in GitHub Desktop.
EDD prevent duplicate cart items
This file contains 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 characters
<?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