Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dwanjuki/b7cf88e4104e77e2e005bfb4354ef5e2 to your computer and use it in GitHub Desktop.
Save dwanjuki/b7cf88e4104e77e2e005bfb4354ef5e2 to your computer and use it in GitHub Desktop.
Add subtotal (!!invoice_subtotal!!) and tax (!!invoice_tax!!) variables to email templates
<?php // copy from below
/**
* Add !!invoice_subtotal!! and !!invoice_tax!! variables to email templates where an Order ID is available.
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_add_order_details_to_email( $data, $email ) {
if ( isset( $data['order_id'] ) ) {
$order = new MemberOrder( $data['order_id'] );
$data['invoice_subtotal'] = isset( $order->subtotal ) ? pmpro_formatPrice( $order->subtotal ) : '';
$data['invoice_tax'] = isset( $order->tax ) ? pmpro_formatPrice( $order->tax ) : '';
}
return $data;
}
add_filter( 'pmpro_email_data', 'my_pmpro_add_order_details_to_email', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment