Created
February 23, 2018 00:42
-
-
Save kimcoleman/8e09a903b96eb455cd8346953e2ccc7a to your computer and use it in GitHub Desktop.
Count the number of times a subscription ID has processed in total with each added order.
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 | |
/** | |
* Count the number of times a subscription ID has processed in total with each added order. | |
*/ | |
function count_transation_ids( $MemberOrder ) { | |
global $wpdb; | |
$orders = $wpdb->get_results("SELECT o.*, UNIX_TIMESTAMP(o.timestamp) as timestamp, l.name as membership_level_name FROM $wpdb->pmpro_membership_orders o LEFT JOIN $wpdb->pmpro_membership_levels l ON o.membership_id = l.id WHERE o.user_id = '$MemberOrder->user_id' AND o.subscription_transaction_id = '$MemberOrder->subscription_transaction_id' ORDER BY timestamp DESC"); | |
$orders_count = count( $orders ); | |
} | |
add_action( 'pmpro_added_order', 'count_transation_ids' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment