/** * Modifying Headers * * Add to your theme functions.php */ add_filter( 'pdf_template_table_headings','custom_pdf_template_table_headings' ); function custom_pdf_template_table_headings( $headers ) { $headers = '<table class="shop_table orderdetails" width="100%">' . '<thead>' . '<tr><th colspan="7" align="left"><h2>' . esc_html__('Order Details', PDFLANGUAGE) . '</h2></th></tr>' . '<tr>' . '<th width="10%" valign="top" align="right">' . __( 'Qty', PDFLANGUAGE ) . '</th>' . '<th width="54%" valign="top" align="left">' . __( 'Product', PDFLANGUAGE ) . '</th>' . '<th width="18%" valign="top" align="right">' . __( 'Price Inc', PDFLANGUAGE ) . '</th>' . '<th width="18%" valign="top" align="right">' . __( 'Total Inc', PDFLANGUAGE ) . '</th>' . '</tr>' . '</thead>' . '</table>'; return $headers; } add_filter( 'pdf_template_line_output' , 'custom_pdf_template_line_output', 10, 2 ); function custom_pdf_template_line_output( $pdflines, $order_id ) { global $woocommerce; $order = new WC_Order( $order_id ); $order_currency = $order->get_currency(); $pdflines = '<table width="100%">'; $pdflines .= '<tbody>'; if ( sizeof( $order->get_items() ) > 0 ) : foreach ( $order->get_items() as $item ) { if ( $item['qty'] ) { $line = ''; // $item_loop++; $_product = $order->get_product_from_item( $item ); $item_name = $item['name']; $item_meta = new WC_Order_Item_Meta( $item['item_meta'] ); if ( $meta = $item_meta->display( true, true ) ) $item_name .= ' ( ' . $meta . ' )'; $line = '<tr>' . '<td valign="top" width="10%" align="right">' . $item['qty'] . ' x</td>' . '<td valign="top" width="54%">' . $item_name . '</td>' . '<td valign="top" width="18%" align="right">' . wc_price( ( $item['line_subtotal'] + $item['line_tax'] ) / $item['qty'], array( 'currency' => $order_currency ) ) . '</td>' . '<td valign="top" width="18%" align="right">' . wc_price( $item['line_subtotal'] + $item['line_tax'], array( 'currency' => $order_currency ) ) . '</td>' . '</tr>' ; $pdflines .= $line; } } endif; $pdflines .= '</tbody>'; $pdflines .= '</table>'; return $pdflines; } /* Close Modifying Headers */