Add Attendee Id to Order Item

Home Forums Ticket Products Event Tickets Plus Add Attendee Id to Order Item

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #947903
    randomwalk
    Participant

    I might be missing something here. I am using product addons with wootickets and I have it populating in the attendee list table. (would be awesome to be able to add these to the exportable CSV file). I am getting stuck with multiple tickets in the same order. Is there already a connection or some way to connect the attendee ID to the order item?

    I am not seeing anything between any of the variables ($existing, $item, $column) when I get the order and thus order items. I am only able to loop through the items, but that doesn’t work when each ticket is on a different line, thus the function is being repeated for each line.

    I am guessing I can add this myself, I just wanted to know if you had something I was missing. Or this could be a nice feature that should be fairly easy to add for people doing custom stuff.

    add_filter( ‘tribe_events_tickets_attendees_table_column’, ‘populate_my_custom_fields_column’, 10, 3 );
    function populate_my_custom_fields_column( $existing, $item, $column ) { //print_r($item[‘attendee_id’]);
    if ( $existing !== ” ) return $existing;

    $order = new WC_Order( $item[‘order_id’] ); //print_r($order); return;
    $items = $order->get_items(); //print_r($items); return; // Add Attendee ID to Order Item

    foreach ($items as $key => $order_item ) { //print_r($order_item); return;
    if ($order_item[‘name’] == $item[‘ticket’]) $item_id = $key; // Not working with multiple tickets on one order, just getting the last order item for each ticket on this order — NEEDS TO BE ATTENDEE ID rather than $item[‘ticket’]
    }

    //$item_meta = $order->get_item_meta( $item_id ); print_r($item_meta); return;// It is here too
    $metadata = $order->has_meta( $item_id );
    foreach ( $metadata as $meta ) {

    $key = strtolower(str_replace(‘ ‘, ‘_’, $meta[‘meta_key’]));
    $key = str_replace(‘-‘, ”, $key);

    if ($key == $column) return $meta[‘meta_value’];

    }

    return ‘-‘;
    }

    I hope this makes sense. 🙂

    #947994
    Barry
    Member

    Hi randomwalk,

    The ticket and the attendee are effectively one and the same – that’s to say, each entry in the attendee screen has an order ID and a ticket ID: the ticket ID is the post ID of the attendee object.

    Does that clarify things at all?

    #948676
    randomwalk
    Participant

    Yes, that makes sense. Unfortunately that does not help me.

    I need to get the custom addons for each ticket or attendee id (the same). I can’t find a place where I can assign this ID to the order item or order item meta. It would be helpful to have the ticket id as an order item meta so you can separate the tickets sold per order.

    Right now my list shows only the custom addons for the last ticket sold in an entire order for each ticket line item.

    Thanks,
    Lindsey

    #948763
    Barry
    Member

    Hi Lindsey,

    I see what you mean and if you’d like to post a feature request (this has the benefit of letting others comment on and up-vote your idea, which can be a useful metric for us) we’ll be more than happy to review it for possible inclusion in a future release 🙂

    As things stand, though, might it not work to assume the order items correlate directly and in the same order to each matching ticket within the same order?

    For example, let’s say order #10 contains 3 ticket purchases:

    Order Item | Product ID/Name ("Ticket Type")
    -----------+--------------------------------
    201        | 10 "Standard"
    202        | 11 "Concession"
    203        | 11 "Concession"

    Let’s also say it resulted in three attendee objects being created in the posts table:

    Attendee Object
    ---------------
    350
    351
    352

    No formal connection is stored in the attendee or order item meta data, yet it seems logical and not too risky to assume the relationship plays out like this:

    Order Item | Product ID/Name | Attendee Object
    -----------+-----------------+----------------
    201        | 10 "Standard"   | 350
    202        | 11 "Concession" | 351
    203        | 11 "Concession" | 352

    Would it be possible for you to use that as a strategy for determining which order item relates to which attendee object? The calculation only needs to be performed once, in a sense, since at the point where attendee objects are created you could save the matching order item ID in the post meta table and retrieve it thereafter.

    Might that offer a means of dealing with this situation?

    #948832
    randomwalk
    Participant

    I could, but if someone ordered other items in between then it wouldn’t work right?

    Currently I added to the wootickets.php which I really don’t want to do…

    foreach ( (array) $order_items as $key => $item ) {

    wc_update_order_item_meta( $key, ‘attendee_id’, $attendee_id );

    }

    It would be great if you could add a do_action(‘something’, $item, $attendee_id); in the foreach. Then developers could do anything when each new ticket is created.

    #948838
    Barry
    Member

    I could, but if someone ordered other items in between then it wouldn’t work right?

    I think it would still be a workable approach, because you could match product IDs.

    It would be great if you could add a do_action(‘something’, $item, $attendee_id); in the foreach. Then developers could do anything when each new ticket is created.

    True!

    I will add that to our issue tracker – I can’t suggest when exactly it will be implemented (and I’m afraid it will not be in the very next release, which is too far into the development cycle for us to add non-critical items) but I definitely agree this is a straightforward and worthy addition to the plugin 🙂

    #948854
    randomwalk
    Participant

    Well, all I can do is ask!

    Thanks for looking into this. You have a very good plugin. I just wish you had more actions and filters for modifying. That is the main reason I use Woocommerce, because it is so easy to modify without changing the base plugin.

    Thanks,
    Lindsey

    #948888
    Barry
    Member

    We’re definitely in favour of adding new hooks where it makes sense – and this seems like a good candidate 🙂

    Thanks again!

    #965797
    Leah
    Member

    Hi there,

    Thanks again for your post. We wanted to get in touch and let you know that although we weren’t able to address this issue in our upcoming 3.10 release, it is still very much a priority. We have a ticket in our system and will be investigating a solution to be released in a future version. Thank you for your patience and support while we work on this!

    Cheers,
    The Events Calendar Team

    #987994
    Leah
    Member

    Hello,

    Thank you again for bringing this issue to our attention. We’re happy to say that we have added a fix for this into our upcoming version 3.11 release. Keep an eye on your Updates page for the new version. If you have any trouble with the update (or are still seeing this problem after you update) please start a new thread and we’d be happy to help out.

    Thank you for your patience while we got this release ready to go!

    Best,
    Leah
    and the rest of The Events Calendar team

Viewing 10 posts - 1 through 10 (of 10 total)
  • The topic ‘Add Attendee Id to Order Item’ is closed to new replies.