Skip to content

Instantly share code, notes, and snippets.

@sc0ttkclark
Forked from skyshab/functions.php
Last active January 27, 2021 15:10
Show Gist options
  • Save sc0ttkclark/16e177dd0f532f606bdd77e63d59f697 to your computer and use it in GitHub Desktop.
Save sc0ttkclark/16e177dd0f532f606bdd77e63d59f697 to your computer and use it in GitHub Desktop.
Reset failed payout status for CT on Order status toggle
<?php
add_action( 'woocommerce_order_status_changed', 'rt_ct_reset_failed_payouts', 9, 4 );
function rt_ct_reset_failed_payouts( $order_id, $status_from, $status_to, $order ) {
if ( 'completed' === $status_to ) {
$payouts = tribe_payouts();
// Get payouts by Order ID.
$payouts->by( 'order', $order_id );
// Get payouts by failed status.
$payouts->by( 'status', \Tribe\Community\Tickets\Payouts::STATUS_FAILED );
// Update those payouts to pending status.
$payouts->set( 'status', \Tribe\Community\Tickets\Payouts::STATUS_PENDING );
// Save the changes to the payouts.
$payouts->save();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment