Skip to content

Instantly share code, notes, and snippets.

@andrewlimaza
Created October 27, 2020 09:04
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save andrewlimaza/135a2f31b6bdaeee4079a0a4bf3c7213 to your computer and use it in GitHub Desktop.
Save andrewlimaza/135a2f31b6bdaeee4079a0a4bf3c7213 to your computer and use it in GitHub Desktop.
Add !!tax!! variable for Paid Memberships Pro email templates
<?php
/**
* Adds an email variable !!tax!! to Paid Memberships Pro emails.
* Only works for email templates that has the !!invoice_id!! variable available.
* Use the Email Templates Admin Editor to add !!tax!! to your email templates.
* Follow this guide to add this code to your site: https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*
* Difficulty: Easy
*/
function my_pmpro_email_variable( $data, $email ) {
if ( isset( $data['invoice_id'] ) ) {
$order = new MemberOrder( $data['invoice_id'] );
$data['tax'] = pmpro_formatPrice( $order->tax );
}
return $data;
}
add_filter( 'pmpro_email_data', 'my_pmpro_email_variable', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment