Es wird das Trusted Shop Template von Germanized missverwendet.
add_filter( 'woocommerce_order_data_store_cpt_get_orders_query', 'handle_custom_query_var', 10, 2 );
function handle_custom_query_var( $query, $query_vars ) {
if ($query_vars['remindersend'] == '0') {
$query['meta_query'][] = array(
'key' => '_reminder_email_sent',
'compare' => 'NOT EXISTS'
);
}
return $query;
}
if (!wp_next_scheduled( 'reminder_cron_hook' ) ) {
wp_schedule_event( strtotime('09:30:00'), 'daily', 'reminder_cron_hook' );
}
add_action( 'reminder_cron_hook', 'reminder_cron_function' );
function reminder_cron_function() {
$remindernachtagen = 14;
$bis = time() - ($remindernachtagen * 86400);
$von = $bis - (14 * 86400);
$args = array(
'status' => 'wc-completed',
'date_completed' => date("Y-m-d",$von).'...'.date("Y-m-d",$bis),
'return' => 'ids',
'remindersend' => '0'
);
$orders = wc_get_orders( $args );
$allmails = WC()->mailer()->emails;
$email = $allmails['WC_TS_Email_Customer_Trusted_Shops'];
foreach ($orders as $order_id) {
$email->trigger( $order_id );
$order = wc_get_order( $order_id );
$order->update_meta_data( '_reminder_email_sent', '1' );
$order->save();
}
}
Mailreminder für Bewertung nach 14 Tagen (WooCommerce)
Es wird das Trusted Shop Template von Germanized missverwendet.