Skip to content

Instantly share code, notes, and snippets.

@SeanChDavis
Created August 31, 2017 19:28
Show Gist options
  • Select an option

  • Save SeanChDavis/cd95ca373bb0c7b55ca07853f19dbb81 to your computer and use it in GitHub Desktop.

Select an option

Save SeanChDavis/cd95ca373bb0c7b55ca07853f19dbb81 to your computer and use it in GitHub Desktop.

Revisions

  1. Sean Davis created this gist Aug 31, 2017.
    14 changes: 14 additions & 0 deletions file.php
    Original 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 );