Created
March 30, 2021 18:41
-
-
Save DumahX/c5bccd941e1d157920c47aef16d65973 to your computer and use it in GitHub Desktop.
This file contains 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 | |
function mepr_completed_recurring_transaction( $event ) { | |
$transaction = $event->get_data(); | |
if ( $transaction->subscription_id > 0 && $transaction->product_id == 76026 ) { | |
// Subscription id is greater than zero, so it's a recurring subscription. | |
// Make sure the transaction's product ID is 76026. | |
$sub = $transaction->subscription(); | |
// Get the transaction count with $sub->txn_count | |
} elseif ( $transaction->subscription_id > 0 ) { | |
// Still a recurring payment, but it's not related to the membership with ID 76026. | |
$sub = $transaction->subscription(); | |
} else { | |
// One-time payment. | |
} | |
} | |
add_action( 'mepr-event-transaction-completed', 'mepr_completed_recurring_transaction' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment