Skip to content

Instantly share code, notes, and snippets.

@remcotolsma
Last active October 2, 2015 09:42
Show Gist options
  • Save remcotolsma/4df01692ea8e619e5e7a to your computer and use it in GitHub Desktop.
Save remcotolsma/4df01692ea8e619e5e7a to your computer and use it in GitHub Desktop.
Easy Digital Downloads - Software Licenses

Easy Digital Downloads - Software Licenses

Post Type Payment

post_type = edd_payment

Meta Keys

_edd_sl_is_renewal = Flag to indicate an renewal.
_edd_sl_renewal_key = The renewal key.

Post Type License

post_type = edd_license

Meta Keys

_edd_sl_payment_id = Connection to payment post.
_edd_sl_key = License key.

Renewal Process

Complete Download Purchase

add_action( 'edd_complete_download_purchase', array( $this, 'process_renewal' ), 0, 4 );

Process Renewal

$license_keys = get_post_meta( $payment_id, '_edd_sl_renewal_key' );

...

self::renew_license( $license_id, $payment_id, $download_id );

Convert Normal Payment To Renewal

SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci;

SET @payment_id = ;
SET @license    = '';

SET @license_id = ( SELECT post_id AS license FROM wp_2_postmeta WHERE meta_key = '_edd_sl_key' AND meta_value = @license );

SELECT @payment_id;
SELECT @license;
SELECT @license_id;

INSERT INTO wp_2_postmeta ( post_id, meta_key, meta_value ) VALUES ( @payment_id, '_edd_sl_is_renewal', 1 );
INSERT INTO wp_2_postmeta ( post_id, meta_key, meta_value ) VALUES ( @payment_id, '_edd_sl_renewal_key', @license );

UPDATE wp_2_postmeta
SET meta_value = @payment_id
WHERE post_id = @license_id
AND meta_key = '_edd_sl_payment_id';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment