Created
September 13, 2021 13:49
-
-
Save ipokkel/0a86efe8fd22dea5de3540ff2855c348 to your computer and use it in GitHub Desktop.
Custom email print invoice for invoices printed from the administrative page Memberships > Orders. This custom template adds some HTML to show the "Paid To" address on the invoice.
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 | |
/** | |
* Custom Template for Print Invoices | |
* | |
* Copy this file into the paid-memberships-pro/pages/ folder of your active theme's directory. | |
* If that folder does not exist, create it. | |
* Keep the name orders-print.php | |
*/ | |
?> | |
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<style> | |
.main, .header { | |
display: block; | |
} | |
.right { | |
display: inline-block; | |
float: right; | |
} | |
.alignright { | |
text-align: right; | |
} | |
.aligncenter { | |
text-align: center; | |
} | |
.invoice, .invoice tr, .invoice th, .invoice td { | |
border: 1px solid; | |
border-collapse: collapse; | |
padding: 4px; | |
} | |
.invoice { | |
width: 100%; | |
} | |
@media screen { | |
body { | |
max-width: 50%; | |
margin: 0 auto; | |
} | |
} | |
</style> | |
</head> | |
<body> | |
<header class="header"> | |
<div> | |
<h2><?php bloginfo( 'sitename' ); ?></h2> | |
</div> | |
<div class="right"> | |
<table> | |
<tr> | |
<td><?php echo __( 'Invoice #: ', 'paid-memberships-pro' ) . ' ' . $order->code; ?></td> | |
</tr> | |
<tr> | |
<td> | |
<?php echo __( 'Date:', 'paid-memberships-pro' ) . ' ' . date_i18n( get_option( 'date_format' ), $order->getTimestamp() ); ?> | |
</td> | |
</tr> | |
</table> | |
</div> | |
</header> | |
<main class="main"> | |
<p> | |
<?php | |
echo pmpro_formatAddress( | |
$order->billing->name, | |
$order->billing->street, | |
'', | |
$order->billing->city, | |
$order->billing->state, | |
$order->billing->zip, | |
$order->billing->country, | |
$order->billing->phone | |
); | |
?> | |
</p> | |
<!-- Add Paid To Address --> | |
<p><strong>Paid To:</strong><br />My Business<br />123 The Street<br />City, XX 12345 USA</p> | |
<!-- end --> | |
<table class="invoice" style="border-width:0px;border-collapse:collapse;"> | |
<tr> | |
<th><?php _e( 'ID', 'paid-memberships-pro' ); ?></th> | |
<th><?php _e( 'Item', 'paid-memberships-pro' ); ?></th> | |
<th><?php _e( 'Price', 'paid-memberships-pro' ); ?></th> | |
</tr> | |
<tr> | |
<td class="aligncenter"><?php echo $level->id; ?></td> | |
<td><?php echo $level->name; ?></td> | |
<td class="alignright"><?php echo pmpro_escape_price( pmpro_formatPrice( $order->subtotal ) ); ?></td> | |
</tr> | |
<?php | |
if ( (float) $order->total > 0 ) { | |
$pmpro_price_parts = pmpro_get_price_parts( $order, 'array' ); | |
foreach ( $pmpro_price_parts as $pmpro_price_part ) { | |
?> | |
<tr style="border-width:1px;border-style:solid;border-collapse:collapse;"> | |
<th colspan="2" style="text-align:right;border-width:1px;border-style:solid;border-collapse:collapse;"> | |
<?php esc_html_e( $pmpro_price_part['label'] ); ?> | |
</th> | |
<td style="text-align:right;border-width:1px;border-style:solid;border-collapse:collapse;"> | |
<?php esc_html_e( $pmpro_price_part['value'] ); ?> | |
</td> | |
</tr> | |
<?php | |
} | |
} | |
?> | |
</table> | |
</main> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment