Skip to content

Instantly share code, notes, and snippets.

@wpweb101
Created August 1, 2019 14:25
Show Gist options
  • Select an option

  • Save wpweb101/8b1e2480fa7d0b2a74f26903b5addaf4 to your computer and use it in GitHub Desktop.

Select an option

Save wpweb101/8b1e2480fa7d0b2a74f26903b5addaf4 to your computer and use it in GitHub Desktop.
Woocommerce PDF Vouchers - Display extra information after product information to check voucher code page
<?php
// Code to display product quantity and product total after product information
add_action('woo_vou_after_productinfo', 'woo_vou_add_extra_product_info', 10, 3 );
function woo_vou_add_extra_product_info( $voucodeid, $item_id, $order_id ){
//get order
$order = wc_get_order( $order_id );
//get order items
$order_items = $order->get_items();
foreach ( $order_items as $key => $item ) {
if( $key == $item_id){
$qty = $item->get_quantity();
$item_total = $item->get_total(); // Get the item line total
echo "<table>";
echo '<tr><th>Voucher Product Name</th><th>Product Quantity</th><th>Product Total</th></tr>';
echo '<tr><td>'.$item->get_name().'</td><td>'.$qty.'</td><td>'.wc_price($item_total).'</td></tr>';
echo '</table>';
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment