If you’ve regenerated all of your WooCommerce order download links and need to resend the order details to all of your customers in WooCommerce, then this is the code you’ll need. It works by sending 20 emails at a time – starting from your most recent orders back to your very first.
I’d recommend letting your customers know that they’ll be receiving these links in advance, and perhaps editing the Processing Orders email template in WooCommerce to clearly show that this is not a new charge, but rather just updated links.
Resend Order Details to All Customers
Use the code below in Code Snippets:
add_action('admin_init', 'resend_wc_order_emails_batch');
function resend_wc_order_emails_batch() {
if ( isset($_GET['resend_wc_emails']) && current_user_can('manage_woocommerce') ) {
$limit = 20; // Number of orders to process per run
$offset = isset($_GET['offset']) ? intval($_GET['offset']) : 0;
$args = array(
'status' => array('processing', 'completed'), // Order statuses to include
'limit' => $limit,
'offset' => $offset,
);
$orders = wc_get_orders($args);
if (empty($orders)) {
wp_die("✅ All emails have been resent. Done!");
}
foreach ($orders as $order) {
WC()->mailer()->emails['WC_Email_Customer_Processing_Order']->trigger($order->get_id());
}
$next_offset = $offset + $limit;
$next_url = admin_url("admin.php?resend_wc_emails=1&offset={$next_offset}");
echo "✅ Sent emails for orders {$offset} to " . ($next_offset - 1) . ".<br>";
echo "<a href='{$next_url}'>Click here to continue...</a>";
exit;
}
}
Use following link to activate, it does 20 orders at a time, you need to click to continue until all are sent
https://website.com/wp-admin/admin.php?resend_wc_emails=1