WooCommerce Box Office
Selling event tickets with WooCommerce Box Office? Need attendee names and ticket IDs?
Standard exports only show the product. Not individual ticket holder details.
Here’s how to export each ticket separately with attendee information.
What this code exports
Each ticket becomes its own row. Columns include:
- Ticket ID (unique identifier)
- First Name (attendee)
- Last Name (attendee)
- Email (attendee)
Plus any custom ticket fields you’ve created in Box Office.
The complete code
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
class WOE_BoxOfficeFields_As_Products { var $fields = array('First Name','Last Name','Email'); // modify names here! Must match to Labels at tab "Ticket Fields" function __construct() { add_filter('woe_get_order_product_fields', function ($fields) { $fields['product_ticket_id'] = array( 'label' => 'Ticket Id', 'colname' => 'Ticket Id', 'checked' => 1 ); foreach($this->fields as $name) $fields['product_'.$name] = array( 'label' => $name, 'colname' => $name, 'checked' => 1 ); return $fields; }); add_filter('woe_fetch_order_products',function ($products,$order,$labels, $format, $static_vals) { $this->line_id = 1; $results = array(); foreach ( $order->get_items('line_item') as $item_id=>$item ) { // seek for assigned tickets $product_data = $products[$item_id]; // take already extracted data for product! $item_meta = get_metadata( 'order_item', $item_id ); $ticket_added = false; foreach($item_meta as $key=>$value) { // parse manual ticket id from HTML! if(preg_match("#ticket-id-(d+)#", $key, $match) ) { $this->add_client_ticket($results, $match[1],$labels,$product_data); $ticket_added = true; } } if( !$ticket_added ) { if ( isset($product_data[ 'line_id' ]) ) $product_data[ 'line_id' ] = $this->line_id++; $results[] = $product_data; // just add item ,it's not ticket!!! } } return $results; },10,5); }// end __construct function add_client_ticket(&$results, $ticket_id,$labels,$product_data) { $data = array( 'product_ticket_id'=>$ticket_id); $product_id = get_post_meta( $ticket_id, '_product', true ); if ( !$product_id ) return; $ticket_product = wc_get_product( $product_id ); //$data['name'] = $ticket_product->get_title(); foreach ( wc_box_office_get_product_ticket_fields( $product_id ) as $field_key => $field ) { // Replace content placeholders with ticket fields. $field_value = get_post_meta( $ticket_id, $field_key, true ); if ( is_array( $field_value ) ) { $field_value = implode( ', ', $field_value ); } $data[ 'product_'.$field['label'] ] = $field_value; } $this->add_ticket($results, $data,$labels,$product_data); } function add_ticket(&$results, $data,$labels,$product_data) { foreach ( $labels as $field => $label ) { if ( $field == 'line_id' ) { $row[ $field ] = $this->line_id++; } elseif ( isset( $data[$field]) ) { // boxoffice fields $row[ $field ] = $data[$field]; } elseif ( isset( $product_data[ $field ] ) ) { $row[ $field ] = $product_data[ $field ]; } else $row[ $field ] = ''; } $results[] = $row; } } new WOE_BoxOfficeFields_As_Products(); |
Setup steps
- Copy the entire code block
- Paste into your theme’s
functions.php - Edit the fields array to match your actual ticket fields:
|
1 |
var $fields = array('First Name', 'Last Name', 'Email', 'Company', 'Dietary Needs'); |
Use the exact labels from your Box Office “Ticket Fields” tab.
- Go to Advanced Order Export for WooCommerce
- Create or edit an export profile
- Open Setup Fields → Products
- You’ll see ticket fields. Check the ones you need
- Save and test on an event order
What your export looks like
Order with 2 tickets to a conference:
| Line ID | Product | Ticket Id | First Name | Last Name | Company | |
|---|---|---|---|---|---|---|
| 1 | Conference Pass | TICKET-123 | John | Smith | [email protected] | Acme Corp |
| 2 | Conference Pass | TICKET-124 | Jane | Doe | [email protected] | TechStart |
Each ticket holder gets their own row.
When you need this
You sell event tickets. Need attendee check-in list with names and emails.
Your security team needs ticket IDs for scanning at the door.
You manage VIP events. Need custom fields like “Meal Preference” or “Shirt Size”.
Customizing the fields
Change the $fields array to match your Box Office setup.
Example for a workshop:
|
1 |
var $fields = array('First Name', 'Last Name', 'Email', 'Skill Level', 'Emergency Contact'); |
Example for a gala:
|
1 |
var $fields = array('First Name', 'Last Name', 'Email', 'Meal Choice', 'Table Preference', 'Plus-One Name'); |
The field names must match exactly. Check your Box Office settings for correct spelling.
Common mistake
The code looks for meta keys like ticket-id-123. Box Office stores ticket IDs this way.
If your Box Office version uses different meta keys, the code won’t find tickets. Export will show only products (one row per product, not per ticket).
One product row, no ticket rows?
Your event product might not have generated tickets yet. Box Office creates tickets after payment completes.
Test with a completed order. Verify tickets exist in Box Office admin.
Pro tip
Need to export only tickets? Uncheck regular product fields. Leave only ticket-specific columns checked.
Add the “Ticket Id” column to your export. Use it for check-in scanning.
Real talk
WooCommerce Box Office stores tickets as custom post types. Each ticket links to an order item.
This code finds those links. Pulls each ticket’s custom fields. Creates one row per ticket.
Perfect for event organizers. Your check-in team gets a clean list. Scan ticket IDs directly from your export. No more manual attendee lists.