Last active
August 29, 2015 14:05
-
-
Save justinstern/19fdbdd1e910cd92c8fa to your computer and use it in GitHub Desktop.
WooCommerce PDF Product Vouchers: Display any voucher numbers on the order emails
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 | |
// 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