Skip to content

Instantly share code, notes, and snippets.

@yratof
Created September 6, 2019 07:48
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 yratof/36cc57583dc8d548f5b34198e59b95fe to your computer and use it in GitHub Desktop.
Save yratof/36cc57583dc8d548f5b34198e59b95fe to your computer and use it in GitHub Desktop.
Get the date of the last payment on a gravity PDF invoice
<?php
// Used within a PDF template
// [...]
$invoice_date = date( $date_format, strtotime( $form_data['misc']['date_time'] ) );
// Fetch last payment date in database
global $wpdb;
$last_payment_date = $wpdb->get_var( $wpdb->prepare( "SELECT date_created FROM {$wpdb->prefix}gf_addon_payment_transaction WHERE lead_id=%d ORDER BY date_created DESC", $entry['id'] ) );
$formatted_last_payment_date = date( $date_format, strtotime( $last_payment_date ) );
$invoice_date = $invoice_date;
if ( $last_payment_date > $form_data['misc']['date_time'] ) {
$invoice_date = $formatted_last_payment_date;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment