Home / Admin / Prevent Duplicate Cart Items
Duplicate Snippet

Embed Snippet on Your Site

Prevent Duplicate Cart Items

Prevents the same item from being added to the cart multiple times.

Code Preview
php
<?php
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 );

Comments

Add a Comment