Last active
January 15, 2025 18:43
-
-
Save rickalday/e699e2137ccbb4b13dbc45f0ab1071cb to your computer and use it in GitHub Desktop.
GiveWP Export Subscription ID
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 givewp_subscription_columns_name( $cols ) { | |
if ( isset( $cols['givewp_subscription_id'] ) ) { | |
$cols['givewp_subscription_id'] = __( 'Subscription ID', 'give' ); | |
} | |
return $cols; | |
} | |
add_filter( 'give_export_donation_get_columns_name', 'givewp_subscription_columns_name' ); | |
function givewp_export_subcription_id_field() { | |
?> | |
<li> | |
<label for="give-export-subscription-id"> | |
<input type="checkbox" checked | |
name="give_give_donations_export_option[givewp_subscription_id]" | |
id="give-export-subscription-id"><?php _e( 'Subscription ID', 'give-recurring' ); ?> | |
</label> | |
</li> | |
<?php | |
} | |
add_action( 'give_export_donation_standard_payment_fields', 'givewp_export_subcription_id_field' ); | |
function givewp_export_subcription_id_data( $data, $payment, $columns, $instance ) { | |
// subscriptions and renewals will have the subscription_id metakey | |
$subscription_payment = $payment->get_meta( 'subscription_id' ); | |
if ( ! empty( $columns['givewp_subscription_id'] )) { | |
if ( $subscription_payment ) { | |
$data['givewp_subscription_id'] = $subscription_payment ; | |
} else { | |
$data['givewp_subscription_id'] = ''; | |
} | |
} | |
return $data; | |
} | |
add_filter( 'give_export_donation_data', 'givewp_export_subcription_id_data', 20, 4 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment