Follow us

Made in the U.S.A.

View Categories

Using a PDF invoicing plugin

2 min read

We get asked all the time about how to display tickets in a pdf for invoicing.  There are many different pdf plugins.  Unfortunately most do not grab the meta info available in woo so tickets are not displayed because they assume only stock woo info is needed to display.

We grabbed the Woocommerce PDF Invoiced and Packing Slip plugin and looked at how this plugin gets their data.

After installing the PDF plugin, you will need to add custom code in your theme functions file.  This is the code for our Platinum Edition.  This is an idea and starting point – it is up to you to create the function.  There is obviously more info you can display but this is a quick help option.

/*********Start WPRAFFLE PDF TICKETS **********/
add_action( ‘wpo_wcpdf_after_order_data’, ‘wpraffle_custom_show_tickets_pdf’, 10, 2 );
function wpraffle_custom_show_tickets_pdf ($template_type, $order) {
global $wpdb;
$order_id = $order->get_id();
$ticket_numbers = $wpdb->get_results(‘select * from ‘.$wpdb->prefix.’rtg_tickets_customer_to_tickets where order_id = “‘.$order_id.'”‘);
$total_tickets = $wpdb->num_rows;
if ($total_tickets > 0) {

?>
<tr class=”custom-user-meta”>
<th>Ticket Numbers:</th>
<td>
<?php
foreach ( $ticket_numbers as $ticket_numbers_result ) {
?>

<?php echo $ticket_numbers_result->ticket_number.'<br />’; ?>

<?php
}
}
?>
</td>
</tr>
<?php
}
?>

This will put the ticket info into the order data for that plugin.  Other plugins have similar needs.

 

FULL DISCLAIMER – this is offered as a free suggestion.  Since this is a workaround for another plugin – we do not support it.  Their plugin can change at any time.   That is YOUR JOB AS A WEB DEVELOPER!    If you need help with this, we are happy to offer it on a paid basis.

Cart