$has_stripe_customers=$wpdb->get_var("SELECT count(user_id) FROM $wpdb->usermeta WHERE meta_key IN ( '_edd_stripe_customer_id', '_edd_stripe_customer_id_test' ) LIMIT 1");
__('Easy Digital Downloads - Stripe Gateway needs to upgrade the customers database; <a href="%s">click here to start the upgrade</a>. <a href="#" onClick="jQuery(this).parent().next(\'p\').slideToggle()">Learn more about this upgrade</a>','easy-digital-downloads').
'</p>'.
'<p style="display: none;">'.
__('<strong>About this upgrade:</strong><br />This upgrade will improve the reliability of associating purchase records with your existing customer records in Stripe by changing their Stripe Customer IDs to be stored locally on their EDD customer record, instead of their user record.','easy-digital-downloads').
'<br /><br />'.
__('<strong>Advanced User?</strong><br />This upgrade can also be run via WPCLI with the following command:<br /><code>wp edd-stripe migrate_customer_ids</code>','easy-digital-downloads').
$total_sql="SELECT COUNT(user_id) as total_users FROM $wpdb->usermeta WHERE meta_key IN ( '_edd_stripe_customer_id', '_edd_stripe_customer_id_test' )";
$results=$wpdb->get_row($total_sql);
$total=$results->total_users;
}
$stripe_user_meta=$wpdb->get_results(
$wpdb->prepare(
"SELECT * FROM $wpdb->usermeta WHERE meta_key IN ( '_edd_stripe_customer_id', '_edd_stripe_customer_id_test' ) ORDER BY umeta_id ASC LIMIT %d,%d;",
$offset,
$number
)
);
if($stripe_user_meta){
foreach($stripe_user_metaas$stripe_user){
$user=get_userdata($stripe_user->user_id);
$email=$user->user_email;
$customer=newEDD_Customer($email);
// If we don't have a customer on this site, just move along.
if(!$customer->id>0){
continue;
}
$stripe_customer_id=$stripe_user->meta_value;
// We should try and use a recurring ID if one exists for this user