/**
     * Order vouchers meta box
     *
     * Displays the order vouchers meta box - for showing and modifying
     * individual vouchers attached to the order
     *
     * @since 1.2
     */
    public function vouchers_meta_box($post)
    {
        $order = wc_get_order($post->ID);
        $order_items = $order->get_items();
        ?>
		<div class="woocommerce_order_vouchers_wrapper">
			<table cellpadding="0" cellspacing="0" class="woocommerce_order_vouchers">
				<thead>
					<tr>
						<th class="thumb" width="1%"><?php 
        _e('Voucher', WC_PDF_Product_Vouchers::TEXT_DOMAIN);
        ?>
</th>
						<th class="voucher_number"><?php 
        _e('Number', WC_PDF_Product_Vouchers::TEXT_DOMAIN);
        ?>
</th>
						<th class="sku"><?php 
        _e('SKU', WC_PDF_Product_Vouchers::TEXT_DOMAIN);
        ?>
</th>
						<th class="data"><?php 
        _e('Data', WC_PDF_Product_Vouchers::TEXT_DOMAIN);
        ?>
</th>
						<th class="expires"><?php 
        _e('Expires', WC_PDF_Product_Vouchers::TEXT_DOMAIN);
        ?>
</th>
						<th class="qty"><?php 
        _e('Qty', WC_PDF_Product_Vouchers::TEXT_DOMAIN);
        ?>
</th>
						<th class="redeem" style="white-space:nowrap;"><?php 
        _e('Mark Redeemed', WC_PDF_Product_Vouchers::TEXT_DOMAIN);
        ?>
&nbsp;<a class="tips" data-tip="<?php 
        _e('Mark the dates that any vouchers are redeemed.  Marking all vouchers redeemed will complete the order.', WC_PDF_Product_Vouchers::TEXT_DOMAIN);
        ?>
" href="#">[?]</a></th>
					</tr>
				</thead>
				<tbody id="order_vouchers_list">

					<?php 
        if (count($order_items) > 0) {
            foreach ($order_items as $item_id => $item) {
                // only voucher items
                if (!isset($item['voucher_id'])) {
                    continue;
                }
                $item['voucher_redeem'] = maybe_unserialize($item['voucher_redeem']);
                $voucher = new WC_Voucher($item['voucher_id'], $post->ID, $item, $item_id);
                if (isset($item['variation_id']) && $item['variation_id'] > 0) {
                    $_product = wc_get_product($item['variation_id']);
                } else {
                    $_product = wc_get_product($item['product_id']);
                }
                // get any user-supplied voucher data (this includes product variation data and user-entered fields like recipient or message)
                $voucher_data = array();
                if (isset($_product->variation_data)) {
                    $voucher_data = $_product->variation_data;
                }
                $voucher_data = array_merge($voucher_data, $voucher->get_user_input_data());
                ?>
						<tr class="item" rel="<?php 
                echo $item_id;
                ?>
">
							<td class="thumb">
								<a href="<?php 
                echo esc_url(admin_url('post.php?post=' . $voucher->id . '&action=edit'));
                ?>
" class="tips" data-tip="<?php 
                echo '<strong>' . __('Voucher ID:', WC_PDF_Product_Vouchers::TEXT_DOMAIN) . '</strong> ' . $voucher->id;
                ?>
"><?php 
                echo $voucher->get_image();
                ?>
</a>
								<?php 
                if ($voucher->file_exists(WC_PDF_Product_Vouchers::get_uploads_path())) {
                    ?>
									<a href="<?php 
                    echo esc_url(add_query_arg(array('action' => 'download', 'product_id' => $item['product_id'], 'item_id' => $item_id, 'voucher_id' => $item['voucher_id'])));
                    ?>
"><?php 
                    esc_html_e('Download', WC_PDF_Product_Vouchers::TEXT_DOMAIN);
                    ?>
</a>
								<?php 
                }
                ?>
							</td>
							<td class="voucher_number" width="1%">
								<?php 
                echo $voucher->get_voucher_number();
                ?>
							</td>
							<td class="sku" width="1%">
								<?php 
                if ($_product->sku) {
                    echo $_product->sku;
                } else {
                    echo '-';
                }
                ?>
							</td>
							<td class="data">

								<?php 
                echo $item['name'];
                ?>
								<?php 
                if (!empty($voucher_data)) {
                    echo '<br/>' . wc_get_formatted_variation($voucher_data, true);
                }
                ?>
							</td>

							<td class="expires" style="width:auto;">
								<input type="text" name="voucher_expiration[<?php 
                echo $item_id;
                ?>
]" id="voucher_expiration_<?php 
                echo $item_id;
                ?>
" maxlength="10" value="<?php 
                echo $voucher->expiration_date ? date("Y-m-d", $voucher->expiration_date) : '';
                ?>
" class="date-picker-field" />
							</td>

							<td class="qty" width="1%">
								<?php 
                echo $item['qty'];
                ?>
							</td>

							<td class="redeem" width="1%">
								<?php 
                foreach ($item['voucher_redeem'] as $i => $redeem) {
                    ?>
									<input type="text" name="voucher_redeem[<?php 
                    echo $item_id;
                    ?>
][<?php 
                    echo $i;
                    ?>
]" id="voucher_redeem_<?php 
                    echo $item_id . '_' . $i;
                    ?>
" class="voucher_redeem date-picker-field" maxlength="10" style="width:85px;" value="<?php 
                    echo $redeem;
                    ?>
" class="date-picker-field" />
									<?php 
                }
                ?>
							</td>

						</tr>
					<?php 
            }
        }
        ?>
				</tbody>
			</table>
		</div>

		<p class="buttons buttons-alt">
			<button type="button" class="button redeem_all_vouchers"><?php 
        _e('Redeem All &uarr;', WC_PDF_Product_Vouchers::TEXT_DOMAIN);
        ?>
</button>
		</p>
		<div class="clear"></div>
		<?php 
    }
 /**
  * Add the voucher number to the order items table of admin
  *
  * @since 2.3.0
  * @param int $item_id The item ID
  * @param array $item The order item
  * @param WC_Order $order The order object
  */
 public function add_voucher_number_to_email_order_item_meta($item_id, $item, $order)
 {
     if ($item['product_id'] > 0 && isset($item['voucher_id']) && $item['voucher_id']) {
         $voucher = new WC_Voucher($item['voucher_id'], $order->id, $item);
         echo '<br/><small>' . __('Voucher Number: ', WC_PDF_Product_Vouchers::TEXT_DOMAIN) . $voucher->get_voucher_number() . '</small>';
     }
 }