Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete WooCommerce customers who are not in the WordPress user section. #51

Merged
merged 2 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions includes/delele-users-form-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
* @return array | posts ID to be delete.
*/
function xt_delete_users_form_process( $data ) {
global $wpdb;
$error = array();
if ( ! current_user_can( 'delete_users' ) ) {
$error[] = esc_html__('You don\'t have enough permission for this operation.', 'wp-bulk-delete' );
Expand All @@ -53,7 +54,15 @@ function xt_delete_users_form_process( $data ) {
if( !wpbd_is_pro() ){
$user_count = wpbulkdelete()->api->do_delete_users( $user_ids );
} else {

$delete_user_who_has_no_order = isset( $data['user_who_has_no_order'] ) ? $data['user_who_has_no_order'] : 'false';
if( !empty( $delete_user_who_has_no_order ) && $delete_user_who_has_no_order == 'on' ){
foreach( $user_ids as $user_id ) {
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}wc_customer_lookup WHERE user_id = %d", $user_id ) );
}
}
$user_count = wpbulkdelete()->api->do_delete_users( $user_ids, (int)$data['reassign_user'] );
$wpdb->query("DELETE FROM {$wpdb->prefix}options WHERE option_name LIKE '%_transient_wc_report_customers_%'");
}
return array(
'status' => 1,
Expand Down
78 changes: 39 additions & 39 deletions languages/wp-bulk-delete.pot
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2024-04-30T09:42:41+00:00\n"
"POT-Creation-Date: 2024-05-18T05:10:09+00:00\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"X-Generator: WP-CLI 2.10.0\n"
"X-Domain: wp-bulk-delete\n"
Expand Down Expand Up @@ -119,7 +119,7 @@ msgstr ""
#: includes/delele-meta-form-functions.php:43
#: includes/delele-posts-form-functions.php:63
#: includes/delele-terms-form-functions.php:29
#: includes/delele-users-form-functions.php:34
#: includes/delele-users-form-functions.php:35
msgid "You don't have enough permission for this operation."
msgstr ""

Expand All @@ -133,7 +133,7 @@ msgstr ""
#: includes/delele-meta-form-functions.php:99
#: includes/delele-posts-form-functions.php:104
#: includes/delele-terms-form-functions.php:36
#: includes/delele-users-form-functions.php:77
#: includes/delele-users-form-functions.php:86
msgid "Sorry, Your nonce did not verify."
msgstr ""

Expand Down Expand Up @@ -166,7 +166,7 @@ msgid "Post Meta"
msgstr ""

#: includes/admin/meta/display-delete-meta.php:54
#: includes/delele-users-form-functions.php:128
#: includes/delele-users-form-functions.php:137
msgid "User Meta"
msgstr ""

Expand Down Expand Up @@ -300,7 +300,7 @@ msgstr ""
#: includes/delele-meta-form-functions.php:87
#: includes/delele-posts-form-functions.php:92
#: includes/delele-terms-form-functions.php:57
#: includes/delele-users-form-functions.php:65
#: includes/delele-users-form-functions.php:74
msgid "Nothing to delete!!"
msgstr ""

Expand Down Expand Up @@ -537,7 +537,7 @@ msgstr ""
#: includes/delele-meta-form-functions.php:299
#: includes/delele-posts-form-functions.php:374
#: includes/delele-posts-form-functions.php:420
#: includes/delele-users-form-functions.php:183
#: includes/delele-users-form-functions.php:192
msgid "older than"
msgstr ""

Expand All @@ -548,28 +548,28 @@ msgstr ""
#: includes/delele-comments-form-functions.php:140
#: includes/delele-meta-form-functions.php:302
#: includes/delele-posts-form-functions.php:377
#: includes/delele-users-form-functions.php:186
#: includes/delele-users-form-functions.php:195
msgid "1 Month"
msgstr ""

#: includes/delele-comments-form-functions.php:141
#: includes/delele-meta-form-functions.php:303
#: includes/delele-posts-form-functions.php:378
#: includes/delele-users-form-functions.php:187
#: includes/delele-users-form-functions.php:196
msgid "6 Months"
msgstr ""

#: includes/delele-comments-form-functions.php:142
#: includes/delele-meta-form-functions.php:304
#: includes/delele-posts-form-functions.php:379
#: includes/delele-users-form-functions.php:188
#: includes/delele-users-form-functions.php:197
msgid "1 Year"
msgstr ""

#: includes/delele-comments-form-functions.php:143
#: includes/delele-meta-form-functions.php:305
#: includes/delele-posts-form-functions.php:380
#: includes/delele-users-form-functions.php:189
#: includes/delele-users-form-functions.php:198
msgid "2 Years"
msgstr ""

Expand All @@ -581,23 +581,23 @@ msgstr ""
#: includes/delele-meta-form-functions.php:310
#: includes/delele-posts-form-functions.php:385
#: includes/delele-posts-form-functions.php:425
#: includes/delele-users-form-functions.php:194
#: includes/delele-users-form-functions.php:203
msgid "days"
msgstr ""

#: includes/delele-comments-form-functions.php:151
#: includes/delele-meta-form-functions.php:313
#: includes/delele-posts-form-functions.php:388
#: includes/delele-posts-form-functions.php:428
#: includes/delele-users-form-functions.php:197
#: includes/delele-users-form-functions.php:206
msgid "Start Date"
msgstr ""

#: includes/delele-comments-form-functions.php:153
#: includes/delele-meta-form-functions.php:315
#: includes/delele-posts-form-functions.php:390
#: includes/delele-posts-form-functions.php:430
#: includes/delele-users-form-functions.php:199
#: includes/delele-users-form-functions.php:208
msgid "End Date"
msgstr ""

Expand Down Expand Up @@ -711,8 +711,8 @@ msgstr ""

#: includes/delele-meta-form-functions.php:255
#: includes/delele-posts-form-functions.php:605
#: includes/delele-users-form-functions.php:134
#: includes/delele-users-form-functions.php:159
#: includes/delele-users-form-functions.php:143
#: includes/delele-users-form-functions.php:168
msgid "equal to ( string )"
msgstr ""

Expand Down Expand Up @@ -778,7 +778,7 @@ msgstr ""

#: includes/delele-meta-form-functions.php:271
#: includes/delele-posts-form-functions.php:607
#: includes/delele-users-form-functions.php:136
#: includes/delele-users-form-functions.php:145
msgid "Value"
msgstr ""

Expand Down Expand Up @@ -823,12 +823,12 @@ msgid "This option will work well with Scheduled Delete, which will help to dele
msgstr ""

#: includes/delele-meta-form-functions.php:341
#: includes/delele-users-form-functions.php:92
#: includes/delele-users-form-functions.php:101
msgid "User roles"
msgstr ""

#: includes/delele-meta-form-functions.php:350
#: includes/delele-users-form-functions.php:102
#: includes/delele-users-form-functions.php:111
msgid "( %s Users )"
msgstr ""

Expand Down Expand Up @@ -964,7 +964,7 @@ msgid "Authors :"
msgstr ""

#: includes/delele-posts-form-functions.php:577
#: includes/delele-users-form-functions.php:224
#: includes/delele-users-form-functions.php:233
msgid "Limit :"
msgstr ""

Expand Down Expand Up @@ -1085,77 +1085,77 @@ msgstr ""
msgid "Select the post taxonomy whose terms you want to delete."
msgstr ""

#: includes/delele-users-form-functions.php:37
#: includes/delele-users-form-functions.php:38
msgid "Please select user role or add user meta key and value."
msgstr ""

#: includes/delele-users-form-functions.php:60
#: includes/delele-users-form-functions.php:69
msgid "%d User(s) deleted successfully."
msgstr ""

#: includes/delele-users-form-functions.php:110
#: includes/delele-users-form-functions.php:119
msgid "Select the user roles from which you want to delete users."
msgstr ""

#: includes/delele-users-form-functions.php:131
#: includes/delele-users-form-functions.php:140
msgid "User Meta Key"
msgstr ""

#: includes/delele-users-form-functions.php:154
#: includes/delele-users-form-functions.php:157
#: includes/delele-users-form-functions.php:163
#: includes/delele-users-form-functions.php:166
msgid "User Email"
msgstr ""

#: includes/delele-users-form-functions.php:178
#: includes/delele-users-form-functions.php:187
msgid "User Registration Date:"
msgstr ""

#: includes/delele-users-form-functions.php:181
#: includes/delele-users-form-functions.php:190
msgid "Delete Users which are"
msgstr ""

#: includes/delele-users-form-functions.php:184
#: includes/delele-users-form-functions.php:193
msgid "registered within last"
msgstr ""

#: includes/delele-users-form-functions.php:191
#: includes/delele-users-form-functions.php:200
msgid "registered between custom"
msgstr ""

#: includes/delele-users-form-functions.php:201
#: includes/delele-users-form-functions.php:210
msgid "Set the reigration date interval for users to delete ( only delete users registered between these dates ) or leave these fields blank to select all users. The dates must be specified in the following format: <strong>YYYY-MM-DD</strong>"
msgstr ""

#: includes/delele-users-form-functions.php:206
#: includes/delele-users-form-functions.php:215
msgid "This option will work well with Scheduled Delete, which will help to delete users of the selected option from the scheduled run date."
msgstr ""

#: includes/delele-users-form-functions.php:229
#: includes/delele-users-form-functions.php:238
msgid "Set the limit over user delete. It will delete only the first limited users. This option will help you in case you have lots of users to delete and script timeout."
msgstr ""

#: includes/delele-users-form-functions.php:246
#: includes/delele-users-form-functions.php:255
msgid "Assign deleted user's data to"
msgstr ""

#: includes/delele-users-form-functions.php:251
#: includes/delele-users-form-functions.php:255
#: includes/delele-users-form-functions.php:260
#: includes/delele-users-form-functions.php:264
msgid "Select User"
msgstr ""

#: includes/delele-users-form-functions.php:261
#: includes/delele-users-form-functions.php:270
msgid "Select the user to whom you want to assign deleted user's data."
msgstr ""

#: includes/delele-users-form-functions.php:279
#: includes/delele-users-form-functions.php:288
msgid "User Who Has No Order"
msgstr ""

#: includes/delele-users-form-functions.php:285
#: includes/delele-users-form-functions.php:294
msgid "Delete WooCommerce Customer Who has no Order"
msgstr ""

#: includes/delele-users-form-functions.php:288
#: includes/delele-users-form-functions.php:297
msgid "Select users who have no order in WooCommerce ( it's only for the customer role )"
msgstr ""

Expand Down