WooCommerce has an extension called Box Office that can be used to sell tickets on your store. We originally created it to run WooConf 2016.
WooCommerce Box Office and Order Barcodes work together and can give people purchasing tickets on your site, barcodes that you can use to verify admission. It’s a good system that allows anyone to quickly verify tickets.
One problem that people run into is the barcodes for the tickets are only available inside the person’s account. They have to be viewed and printed on the website. I recently had a user who was looking to include the order barcodes on the order emails. Here’s the solution that she came up with.
First create a folder in your theme or child theme called
woocommerce-box-office. We can use this folder as a place to create overrides for the Box Office templates.
Then inside this folder, create another folder called
order. Then copy the
order-tickets.php file out of the
woocommerce-box-office/templates/order/ folder in the plugin and place it into the new directory in your theme. The path in your theme should be
Next we want to modify this section:
<dl class="purchased-tickets"> <?php foreach ( $tickets as $ticket ) : ?> <dt> <a href="<?php echo esc_url( wcbo_get_my_ticket_url( $ticket->ID ) ); ?>"> <?php echo esc_html( $ticket->post_title ); ?> </a> <?php if ( 'pending' === $ticket->post_status ) : ?> — <span class="pending"><?php _e( 'Pending', 'woocommerce-box-office' ); ?></span> <?php endif; ?> </dt> <dd class="description"> <?php echo wc_box_office_get_ticket_description( $ticket->ID, $fields_format ); ?> </dd> <?php endforeach; ?> </dl>
so that it will be like this:
Now when the email is set to the customer, it will have the barcode for each ticket in it. Here’s a screenshot from an order email.
You can also customize this further by modifying the email template, but this should get you started.
So now if you want to include the ticket barcodes in your customer emails, you can. If you have any questions, please let me know in the comments.
Leave a Reply