Skip to content

Instantly share code, notes, and snippets.

@ChrisFlannagan
Created August 3, 2016 20:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save ChrisFlannagan/ac250f86f2625bfc40d6a95d791fd56d to your computer and use it in GitHub Desktop.
Save ChrisFlannagan/ac250f86f2625bfc40d6a95d791fd56d 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 );
}
}
}
?>
@davidjmorin
Copy link

Is this code still valid after 7 years?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment