To display FooEvents attendee names, booking slot and date in our WooCommerce PDF invoice, you need to fetch the attendee details stored in the order meta and modify the WooCommerce PDF Invoice template accordingly. Make sure to retrieve the attendee’s first and last name from the FooEvents order data. To do so add the code below to your functions.php file of your child theme:

global $fooeventsLoopCount;
$fooeventsLoopCount = 0;

add_filter('woocommerce_pdf_invoices_item_meta', function($val, $item, $order_data) {

    global $fooeventsLoopCount;

    $meta = $order_data->get_meta('WooCommerceEventsOrderTickets');
    if(!is_array($meta) || empty($meta)) {
        return '';
    }

    $metaMapped = array();
    foreach($meta as $met) {

        foreach($met as $me) {
            $metaMapped[] = $me;    
        }
    }

    $val = '
'; $kosten = $item->get_meta('pa_kosten'); if($kosten == "nein") { $val .= 'Kein Mitglied
'; } else { $val .= 'Mitglied
'; } $data = $metaMapped[$fooeventsLoopCount]; if(!is_array($data)) { return $val; } if(isset($data['WooCommerceEventsBookingOptions']) && !empty($data['WooCommerceEventsBookingOptions'])) { $val .= 'Teilnehmer: ' . $data['WooCommerceEventsAttendeeName'] . ' ' . $data['WooCommerceEventsAttendeeLastName'] . '
'; $val .= 'Datum: ' . $data['WooCommerceEventsBookingOptions']['date_label'] . '
'; $val .= 'Ort: ' . $data['WooCommerceEventsBookingOptions']['slot_label'] . '
'; $fooeventsLoopCount += 1; } $val .= '
'; return $val; }, 20, 3);

Leave a Reply

Your email address will not be published. Required fields are marked *