Display ticket number in woocommerce invoice email

Home Forums Ticket Products Event Tickets Plus Display ticket number in woocommerce invoice email

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #1136324
    Juan Gerardo Mexia
    Participant

    Hi.
    We see that the ticket number displays in the email that woocommerce sends to the event administrator, but not in the invoice email sent to the client. How can we display the ticket number in the invoice email? The client prints that email and we need to pair the invoice with the ticket number.
    *Note: we used a custom php code to show in the invoice email all the custom fields from the ticket, so we disabled the “ticket email” sending. The client only receives one email, the invoice from Woocommerce. That’s why it’s important to have the ticket number in that email.

    Thank you!!!!

    #1136514
    Brook
    Participant

    Howdy Juan,

    Nice work getting the attendee meta info in there. Inserting the ticket ID should be pretty similar. You will want run:

    get_post_meta( $order_id, '_unique_id', true );

    Where $order_id is going to be the same ID you used to get the attendee meta for an order.

    Does that make sense?

    Cheers!

    – Brook

    #1136520
    Juan Gerardo Mexia
    Participant

    Hi Brook!!!
    The code is not mine, I used it from another thread in the forum.
    I’ll paste here the code, perhaps you could help me to integrate your piece of coding in there?
    That would be really helpful!!!!!! Specially since I’m only beginning to learn PHP.

    /*—-[UPDATE THE ORDER WITH THE META VALUES]—–*/
    function mse_fieldset_update_order_meta( $order_id ) {

    $order = new WC_Order( $order_id );
    $order_items = $order->get_items();
    $post_custom_keys = get_post_meta( $order_id );
    $fieldset_questions = array();

    foreach ($order_items as $item_id => $item) {
    if (array_key_exists(‘_tribe_tickets_meta’, $post_custom_keys)) {
    $fs_questions = Tribe__Tickets_Plus__Main::instance()->meta()->get_meta_fields_by_ticket( $item[‘product_id’] );
    $fs_answers = get_post_custom_values(‘_tribe_tickets_meta’, $order_id);
    $fs_answers = unserialize($fs_answers[0]);

    for($n = 1; $n <= $item[‘qty’]; $n++) {
    $i = $n-1;
    foreach ($fs_questions as $fs_question) {
    foreach ($fs_answers as $product_id => $fs_answer ) {
    if ($product_id == $item[‘product_id’]) {
    if ($fs_question->type == “checkbox”) {
    $fs_items = array();
    $search_length = strlen($fs_question->slug);
    foreach ($fs_answer[$i] as $key => $value) {
    if (substr($key, 0, $search_length) == $fs_question->slug) {
    $fs_items[] = $value;
    }
    }
    $fieldset_questions[$item_id][] = array(
    ‘type’ => $fs_question->type,
    ‘label’ => $fs_question->label,
    ‘slug’ => $fs_question->slug,
    ‘required’ => $fs_question->required,
    ‘answer’ => implode (“|”, $fs_items),
    );

    } else {
    $fieldset_questions[$item_id][] = array(
    ‘type’ => $fs_question->type,
    ‘label’ => $fs_question->label,
    ‘slug’ => $fs_question->slug,
    ‘required’ => $fs_question->required,
    ‘answer’ => $fs_answer[$i][$fs_question->slug],
    );
    }
    }
    }
    }
    }
    }
    }
    update_post_meta( $order_id, ‘_mse_order_fieldset_meta’, $fieldset_questions);
    }
    add_action(‘woocommerce_checkout_update_order_meta’, ‘mse_fieldset_update_order_meta’);

    /*——[DISPLAY CUSTOM META ON ORDER PAGE]——-*/
    function mse_before_order_itemmeta( $item_id, $item, $_product ){
    global $post;
    $order = new WC_Order( $post->ID );
    $order_items = $order->get_items();
    $post_custom_keys = get_post_meta( $post->ID );
    if (array_key_exists(‘_mse_order_fieldset_meta’, $post_custom_keys)) {
    $fieldset_questions = get_post_custom_values(‘_mse_order_fieldset_meta’, $order->ID);
    $fieldset_questions = unserialize($fieldset_questions[0]);
    foreach ($fieldset_questions as $item => $fs_questions) {
    if ($item_id == $item) {
    foreach ($fs_questions as $fs_question => $fs_meta) {
    if (strpos($fs_meta[‘answer’], ‘|’)) {
    $fs_meta[‘answer’] = str_replace(‘|’, ‘, ‘, $fs_meta[‘answer’]);
    }
    echo ‘<br><b>’ . $fs_meta[‘label’] . ‘: </b>’ . $fs_meta[‘answer’];
    }
    }
    }
    }
    }

    add_action( ‘woocommerce_before_order_itemmeta’, ‘mse_before_order_itemmeta’, 10, 3 );

    /*—-[ADD CUSTOM META TO ORDER EMAIL/INVOICE]—-*/
    function mse_woocommerce_order_item_meta_end( $item_id, $item, $order ) {
    $order_items = $order->get_items();
    $post_custom_keys = get_post_meta( $order->id );
    if (array_key_exists(‘_mse_order_fieldset_meta’, $post_custom_keys)) {
    $fieldset_questions = get_post_custom_values(‘_mse_order_fieldset_meta’, $order->id);
    $fieldset_questions = unserialize($fieldset_questions[0]);
    foreach ($fieldset_questions as $item => $fs_questions) {
    if ($item_id == $item) {
    foreach ($fs_questions as $fs_question => $fs_meta) {
    if (strpos($fs_meta[‘answer’], ‘|’)) {
    $fs_meta[‘answer’] = str_replace(‘|’, ‘, ‘, $fs_meta[‘answer’]);
    }
    echo ‘<br><b>’ . $fs_meta[‘label’] . ‘: </b>’ . $fs_meta[‘answer’];

    }
    }
    }
    }
    }

    add_action( ‘woocommerce_order_item_meta_end’, ‘mse_woocommerce_order_item_meta_end’, 10, 3 );

    #1136793
    Brook
    Participant

    No worries. I will do my best to help. We are a bit limited in how much exact code we can provide, just due to the extraordinary amount of time it usually takes to provide exact code (we would go bankrupt). But I’ll do my best.

    It looks to me like you should find this line:

    function mse_woocommerce_order_item_meta_end( $item_id, $item, $order ) {

    And insert this new line directly below that:

    echo '<br><b>Ticket ID</b>' . get_post_meta( $order->id, '_unique_id', true );

    And I believe that will do the trick! Does it?

    Cheers!
    – Brook

    #1136952
    Juan Gerardo Mexia
    Participant

    Hi Brook.
    Unfortunately, now any part of the code is working.
    I updated your plugins today, and looks like with the update the code is not working anymore.
    Do you have a fix for this for the current code, or is there some way to revert the plugins to their previous version?
    🙁

    #1137216
    Brook
    Participant

    Howdy again Juan,

    I am sorry I do not have a fix  for that. Right now our Meta API is still pretty young, and it does not surprise me that modifications to it will break often. We have ticketed a much better method for pulling data out of it in the future, one that would be unlikely to break. But until then it is going to be a bit premature for us to be writing lots of modifications for it.

    Perhaps the original author can help? Another option would be to suggest as a feature “Including Attendee Meta in WooCommerce Emails”.

    I wish I had better news here. Let me know if you have any more questions. 🙁

    – Brook

    #1137250
    Juan Gerardo Mexia
    Participant

    Thank you for all your help Brook. As it happens, we found out that with the current version of the plugin, after the update, all attendee meta data is now displayed in the ticket email by default, which is a far better solution to this issue.
    We’ll use the default configuration for now on instead.
    Again, thank you!

    #1137261
    Brook
    Participant

    Ahh yes, I should have thought to mention that. I am happy that will work for now! Is there anything missing/any reason you would prefer to use the old emails if they were available? We are working on improving these emails so feedback is very much appreciated.

    Cheers!

    – Brook

    #1137567
    Juan Gerardo Mexia
    Participant

    Hi Brook, tanx!
    We were thinking on using the previous version of the plugin because what we need is for the client to have all the information from the custom fields of the ticket visible in a document. It’s easier now for us to use the default event tickets plus emailing system, since it has all the info we need.
    However, it would be GREAT if your plugin tickets could be compatible with the WooCommerce Email Customizer plugin, which we bought and use to improve the layout and design of the default woocommerce emails. If we could also edit the Events… ticket email, that would be beyond fantastic.
    Hopefully, that could be incorporated in future versions of the plugin.

    #1138545
    Brook
    Participant

    Thank you for getting back Juan. I really appreciate the feedback.

    We do allow customization of the Tickets email view theme overrides ( Tutorial: themer’s Guide ). However, that requires some code knowhow so it might not be what you’re looking for.

    Thanks again for letting us know what’s important. Cheers!

    – Brook

    #1146666
    Support Droid
    Keymaster

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.

Viewing 11 posts - 1 through 11 (of 11 total)
  • The topic ‘Display ticket number in woocommerce invoice email’ is closed to new replies.