Skip to content

Instantly share code, notes, and snippets.

@andrewlimaza
Created October 19, 2020 07:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewlimaza/9d2621b6fd921344fed8e85f129d7f3e to your computer and use it in GitHub Desktop.
Save andrewlimaza/9d2621b6fd921344fed8e85f129d7f3e to your computer and use it in GitHub Desktop.
Add !!invoice_subtotal!! and !!invoice_tax!! to email templates Paid Memberships Pro.
<?php
/**
* This creates two variables !!invoice_subtotal!! and !!invoice_tax!! to email templates where the !!invoice_id!! is available.
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_add_invoice_details_to_email( $data, $email ) {
if ( isset( $data['invoice_id'] ) ) {
$invoice = new MemberOrder($data['invoice_id']);
$data['invoice_subtotal'] = isset( $invoice->subtotal ) ? pmpro_formatPrice( $invoice->subtotal ) : '';
$data['invoice_tax'] = isset( $invoice->tax ) ? pmpro_formatPrice( $invoice->tax ) : '';
}
return $data;
}
add_filter( 'pmpro_email_data', 'my_pmpro_add_invoice_details_to_email', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment