Skip to content

Instantly share code, notes, and snippets.

@rafsuntaskin
Last active October 15, 2023 08:34
Show Gist options
  • Save rafsuntaskin/6e2409f93b2c88b987eeea0d69bd9438 to your computer and use it in GitHub Desktop.
Save rafsuntaskin/6e2409f93b2c88b987eeea0d69bd9438 to your computer and use it in GitHub Desktop.
Plain Ticket Meta data on WooCommerce Order data
<?php
add_action( 'woocommerce_order_status_changed', 'etp_modify_saved_order_meta', 10, 2 );
function etp_modify_saved_order_meta( $order_id, $from_status = null ) {
if ( ! class_exists( 'Tribe__Tickets_Plus__Meta' ) ) {
return;
}
$order = wc_get_order( $order_id );
$saved_meta = $order->get_meta( Tribe__Tickets_Plus__Meta::META_KEY, true );
$restructured_data = [];
foreach ( $saved_meta as $product_id => $attendees ) {
foreach ( $attendees as $attendee ) {
$product = wc_get_product( $product_id );
$attendee['product_id'] = $product_id;
$attendee['product_sku'] = $product->get_sku();
$restructured_data[] = $attendee;
}
}
$order->delete_meta_data( '_etp_ticket_data' );
$order->add_meta_data( '_etp_ticket_data', $restructured_data );
$order->save();
}
@ajamessmith
Copy link

ajamessmith commented Oct 15, 2023

Hi Im looking for something like this, does this do what I think it should do...

Add each attendee records ticket variation to the woocommerce order meta, eg security code and ticket ID

I also have the pdf add on, is there a way of adding this as a field as well (the latter part of the URL which I can append)

image

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment