Skip to content

Instantly share code, notes, and snippets.

@DumahX
Created March 30, 2021 18:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DumahX/c5bccd941e1d157920c47aef16d65973 to your computer and use it in GitHub Desktop.
Save DumahX/c5bccd941e1d157920c47aef16d65973 to your computer and use it in GitHub Desktop.
<?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