Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save JarrydLong/4ae798023ebb23d36faf5bae0dbcdeef to your computer and use it in GitHub Desktop.
Save JarrydLong/4ae798023ebb23d36faf5bae0dbcdeef to your computer and use it in GitHub Desktop.
Adds payment method variable to Paid Memberships Pro emails that can be included using the Paid Memberships Pro Email Templates Add On
<?php
/**
* Adds !!payment_method!! variable to be used with the
* Paid Memberships Pro Email Templates Add On.
* This data will be available for all Paid Memberships Pro emails.
* Add the below code to your PMPro Customizations Plugin and
* edit the email templates you want to add this to.
*/
function add_payment_method_to_pmpro_emails( $data, $email ) {
$data['payment_method'] = 'N/A';
$invoice_id = null;
// Get payment method from invoice
if ( isset( $data['invoice_id'] ) ) {
$invoice_id = $data['invoice_id'];
}
if ( ! empty( $invoice_id ) ) {
$invoice = new MemberOrder( $invoice_id );
$payment_method = $invoice->gateway;
$data['payment_method'] = ucwords( $payment_method );
}
return $data;
}
add_filter( 'pmpro_email_data', 'add_payment_method_to_pmpro_emails', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment