Skip to content

Instantly share code, notes, and snippets.

@justinstern
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justinstern/19fdbdd1e910cd92c8fa to your computer and use it in GitHub Desktop.
Save justinstern/19fdbdd1e910cd92c8fa to your computer and use it in GitHub Desktop.
WooCommerce PDF Product Vouchers: Display any voucher numbers on the order emails
<?php
// Add the following to the end of your theme's functions.php
// Add the following to the end of your theme's functions.php
add_action( 'woocommerce_email_order_meta', 'wc_pdf_product_vouchers_email_voucher_numbers', 10, 3 );
function wc_pdf_product_vouchers_email_voucher_numbers( $order, $sent_to_admin, $plain_text ) {
if ( class_exists( 'WC_PDF_Product_Vouchers_Order' ) ) {
$vouchers = WC_PDF_Product_Vouchers_Order::get_vouchers( $order );
if ( count( $vouchers ) ) {
echo '<h2>Voucher Numbers</h2>';
echo '<ul>';
foreach ( $vouchers as $voucher ) {
$item = $voucher->get_item();
echo '<li>';
if ( $item['qty'] > 1 ) {
echo $item['qty'] . ' x ';
}
echo $voucher->get_product_name() . ' ' . $voucher->get_voucher_number();
echo '</li>';
}
echo '</ul>';
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment