Exemplo n.º 1
0
include dirname(__FILE__) . '/../../../init.php';
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
$now = date("Y-m-d");
$period = Configuration::get('PS_COLLECT_REVIEW_PERIOD_DAY');
$minus = date('Y-m-d', strtotime($now . ' - ' . $period . ' day'));
if ($orders = CollectReview::getAllOrderByDay($minus)) {
    $link = new Link();
    foreach ($orders as $value) {
        $order = new Order($value);
        $customer = new Customer($order->id_customer);
        $emailTo = $customer->email;
        $products_order = $order->getProducts();
        $products = array();
        foreach ($products_order as $item) {
            $cover = Product::getCover($item['product_id']);
            array_push($products, array('name' => $item['product_name'], 'price' => Tools::displayPrice($item['price']), 'quantity' => StockAvailable::getQuantityAvailableByProduct($item['product_id']), 'link' => $link->getProductLink($item['product_id']) . '#reviews', 'image' => $link->getImageLink($item['image']->id, $cover['id_image'], 'large_default')));
        }
        $template = 'collectReview';
        $subject = 'Оставьте отзыв';
        $product_list_html = CollectReview::getEmailTemplateContent('collectReview.tpl', Mail::TYPE_HTML, $products);
        $templateVars = array('{products}' => $product_list_html);
        $admin_mails = Configuration::get('PS_SHOP_EMAIL');
        $te = Mail::Send(1, $template, $subject, $templateVars, $emailTo);
    }
    $r = CollectReview::deactivate($orders);
    echo 'Письма отправлены';
} else {
    echo 'Не кому отправлять письма';
}