• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
Easy Digital Downloads a2z

Easy Digital Downloads a2z

Easy Digital Downloads a2z

  • Home
  • Plugins
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / APIs / edd_get_payment() – Retrieves an instance of EDD_Payment for a specified ID.

You appear to be a bot. Output may be restricted

Description

Retrieves an instance of EDD_Payment for a specified ID.

Usage

$EDD_Payment|false = edd_get_payment( $payment_or_txn_id, $by_txn );

Parameters

$payment_or_txn_id
( mixed ) optional –
$by_txn
( bool ) optional – Is the ID supplied as the first parameter

Returns

EDD_Payment|false false|object EDD_Payment if a valid payment ID, false otherwise.

Source

File name: easy-digital-downloads/includes/payments/functions.php
Lines:

1 to 38 of 38
function edd_get_payment( $payment_or_txn_id = null, $by_txn = false ) {
  global $wpdb;

  if ( $payment_or_txn_id instanceof WP_Post || $payment_or_txn_id instanceof EDD_Payment ) {
    $payment_id = $payment_or_txn_id->ID;
  } elseif ( $by_txn ) {
    if ( empty( $payment_or_txn_id ) ) {
      return false;
    }

    $query      = $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_edd_payment_transaction_id' AND meta_value = '%s'", $payment_or_txn_id );
    $payment_id = $wpdb->get_var( $query );

    if ( empty( $payment_id ) ) {
      return false;
    }
  } else {
    $payment_id = $payment_or_txn_id;
  }

  if ( empty( $payment_id ) ) {
    return false;
  }

  $cache_key = md5( 'edd_payment' . $payment_id );
  $payment   = wp_cache_get( $cache_key, 'payments' );

  if ( false === $payment ) {
    $payment = new EDD_Payment( $payment_id );
    if ( empty( $payment->ID ) || ( ! $by_txn && (int) $payment->ID !== (int) $payment_id ) ) {
      return false;
    } else {
      wp_cache_set( $cache_key, $payment, 'payments' );
    }
  }

  return $payment;
}
 

 View on GitHub View on Trac

Published: 26th November 2019 | Last updated: 23rd February 2021

Primary Sidebar

Information

Function name: edd_get_payment
Plugin ref: Easy Digital Downloads
Version: 2.11.6
Sourcefile: includes/payments/functions.php
File ref: includes/payments/functions.php
Deprecated?: No
API Letters: E,G,P

Footer

Easy Digital Downloads a2z
Easy Digital Downloads a2z
Easy Digital Downloads a2z
WordPress 5.9.3
WordPress a2z
WordPress core a2z
Genesis Theme Framework a2z
Jetpack a2z
WordPress develop tests
Easy Digital Downloads a2z
WooCommerce a2z
Yoast SEO a2z
WordPress Blocks

Site:  edd.wp-a2z.org
© Copyright Easy Digital Downloads a2z 2014-2022. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins

  • Home
  • Blog
  • Sitemap
  • Sites