Skip to content

Instantly share code, notes, and snippets.

@sonipb
Forked from ChrisFlannagan/woo-reminders.php
Created August 25, 2017 08:29
Show Gist options
  • Save sonipb/d975807f04d1ba8be857881d40338ce4 to your computer and use it in GitHub Desktop.
Save sonipb/d975807f04d1ba8be857881d40338ce4 to your computer and use it in GitHub Desktop.
<?php
function email_past_due() {
global $wpdb;
$mailer = WC_Emails::instance();
$date = date( "Y-m-d H:i:s", current_time( 'timestamp' ) + 86400 * 7 );
$due_orders = $wpdb->get_col( $wpdb->prepare( "
SELECT posts.ID
FROM {$wpdb->posts} AS posts
WHERE posts.post_type = 'shop_order'
AND posts.post_status = 'wc-pending'
AND posts.post_date < %s
", $date ) );
if ( $due_orders ) {
foreach ( $due_orders as $due_order ) {
$order = wc_get_order( $due_order );
$mailer->customer_invoice( $order );
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment