Created
August 3, 2016 20:34
-
-
Save ChrisFlannagan/ac250f86f2625bfc40d6a95d791fd56d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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
Is this code still valid after 7 years?