Forked from andrewlimaza/add-invoice-details-to-email-pmpro.php
Last active
May 2, 2025 16:38
-
-
Save dwanjuki/b7cf88e4104e77e2e005bfb4354ef5e2 to your computer and use it in GitHub Desktop.
Add subtotal (!!invoice_subtotal!!) and tax (!!invoice_tax!!) variables to email templates
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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