-
-
Save sonipb/d975807f04d1ba8be857881d40338ce4 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