Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pippinsplugins/3966310 to your computer and use it in GitHub Desktop.
Save pippinsplugins/3966310 to your computer and use it in GitHub Desktop.
Retrieve the purchase ID based on the purchase key
<?php
/**
* Retrieve the purchase ID based on the purchase key
*
* @access public
* @since 1.2.3
*
* @param string $key the purchase key to search for
* @return int $order_id
*/
function edd_get_purchase_id_by_key( $key ) {
$payments = edd_get_payments( array( 'meta_key' => '_edd_payment_purchase_key', 'number' => 1 ) );
if ( $payments )
return $payments[0]->ID;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment