-
-
Save skyshab/4c906aaaa98a3e904dc6c19522ef932a to your computer and use it in GitHub Desktop.
Force Attendee Regeneration WooCommerce
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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