function cw_review_prepare_and_send_reminder($params, $return)
{
    global $tables, $config;
    // Follow up email notifications
    if (!empty($config['estore_products_review']['amount_days_order_review_product'])) {
        $count_days = $config['estore_products_review']['amount_days_order_review_product'];
        $count_seconds = SECONDS_PER_DAY * $count_days;
        $check_seconds = cw_core_get_time() - $count_seconds;
        $status_remind = $config['estore_products_review']['order_status_start_reminder'];
        $not_reviews_products = cw_query("\n            SELECT DISTINCT di.product_id, ui.customer_id\n            FROM {$tables['docs']} d\n            LEFT JOIN {$tables['docs_items']} di ON di.doc_id = d.doc_id\n            LEFT JOIN {$tables['docs_user_info']} ui ON ui.doc_info_id = d.doc_info_id\n            LEFT JOIN {$tables['products_reviews']} r ON r.product_id = di.product_id\n            LEFT JOIN {$tables['products_reviews_reminder']} rr ON rr.product_id = di.product_id\n                AND ui.customer_id = rr.customer_id\n            WHERE d.status_change < {$check_seconds} AND d.type = 'O' AND d.status = '{$status_remind}'\n                AND ui.customer_id <> 0 AND r.product_id IS NULL\n                AND rr.product_id IS NULL AND di.product_id IS NOT NULL\n            ORDER BY d.doc_id\n        ");
        if (!empty($not_reviews_products) && is_array($not_reviews_products)) {
            $customer_products = array();
            foreach ($not_reviews_products as $_r) {
                $customer_products[$_r['customer_id']][] = $_r['product_id'];
            }
            cw_review_send_order_review_reminder_email($customer_products);
        }
    }
    return $return;
}
<?php

if (constant('IS_AJAX') && is_numeric($doc_id)) {
    global $tables;
    $remind_products = cw_query("\n        SELECT DISTINCT di.product_id, ui.customer_id\n        FROM {$tables['docs']} d\n        LEFT JOIN {$tables['docs_items']} di ON di.doc_id = d.doc_id\n        LEFT JOIN {$tables['docs_user_info']} ui ON ui.doc_info_id = d.doc_info_id\n        WHERE d.doc_id = {$doc_id}\n    ");
    if (!empty($remind_products) && is_array($remind_products)) {
        $customer_products = array();
        foreach ($remind_products as $_r) {
            $customer_products[$_r['customer_id']][] = $_r['product_id'];
        }
        cw_review_send_order_review_reminder_email($customer_products);
        $lbl_name = 'lbl_email_sent_successfully';
    } else {
        $lbl_name = 'lbl_email_not_sent';
    }
    cw_add_ajax_block(array('id' => 'additional_doc_action', 'action' => 'update', 'content' => cw_get_langvar_by_name($lbl_name, NULL, FALSE, TRUE)));
}