Skip to content

Instantly share code, notes, and snippets.

@skyshab
Forked from rafsuntaskin/functions.php
Last active January 22, 2021 18:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save skyshab/4c906aaaa98a3e904dc6c19522ef932a to your computer and use it in GitHub Desktop.
Save skyshab/4c906aaaa98a3e904dc6c19522ef932a to your computer and use it in GitHub Desktop.
Force Attendee Regeneration WooCommerce
<?php
// Add action to the "order actions" dropdown
add_filter( 'woocommerce_order_actions', function( $actions ) {
$actions['tribe_force_regenerate_ticket'] = __( 'Regenerate Attendees' );
return $actions;
});
// Execute action when selected from order actions dropdown
add_action( 'woocommerce_order_action_tribe_force_regenerate_ticket', function( $order ) {
// The order ID
$order_id = $order->get_id();
// Remove the flag from the order metat that indicates the attendee is already generated
update_post_meta( $order_id, '_tribe_has_tickets', 0 );
// Regenerate attendees
tribe( 'tickets-plus.commerce.woo' )->generate_tickets( $order_id );
// Add note to order history
$order->add_order_note('Force regenerated attendees');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment