mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-05-05 12:32:23 +08:00
https://github.com/easydigitaldownloads/library/blob/master/_checkout/prevent-duplicate-cart-items.html
10 lines
360 B
Text
10 lines
360 B
Text
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') && 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 );
|