Created
December 5, 2013 23:06
-
-
Save justinstern/7815673 to your computer and use it in GitHub Desktop.
Display any voucher numbers from voucher items in the order on the New Order admin email. To use this snippet simply paste into the bottom of your theme's functions.php
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 | |
| // Displays any voucher numbers on the New Order admin email | |
| add_action( 'woocommerce_email_order_meta', function( $order, $is_admin ) { | |
| if ( $is_admin ) { | |
| $voucher_numbers = array(); | |
| $order_items = $order->get_items(); | |
| if ( count( $order_items ) > 0 ) { | |
| foreach ( $order_items as $item ) { | |
| if ( $item['product_id'] > 0 && isset( $item['voucher_id'] ) && $item['voucher_id'] ) { | |
| $voucher = new WC_Voucher( $item['voucher_id'], $order->id, $item ); | |
| $voucher_numbers[] = $voucher->get_voucher_number(); | |
| } | |
| } | |
| } | |
| echo "<p><strong>Email Certificate Number:</strong> " . implode( ', ', $voucher_numbers ) . "</p>"; | |
| } | |
| }, 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment