#вопрос
Доброго времени суток !
Помогите пожалуйста.
Клиент оформляет заказ на подарочный сертификат с сайта, заполняет данные тому, кому надо отправить и т.д.
`
add_action('woocommerce_order_status_completed', 'sertificate_cron_on_order_complete', 10, 1);
function sertificate_cron_on_order_complete($order_id)
{
$order = wc_get_order($order_id);
$order_items = $order->get_items();
foreach ($order_items as $order_item_id => $order_item) {
$name = $order_item->get_name();
if ($name == 'Сертификат') {
$price = wc_get_order_item_meta($order_item_id, 'Номинал', true);
$mail = wc_get_order_item_meta($order_item_id, 'E-mail получателя', true);
$from = wc_get_order_item_meta($order_item_id, 'От кого', true);
$msg = wc_get_order_item_meta($order_item_id, 'Текст поздравления', true);
$date = wc_get_order_item_meta($order_item_id, 'Дата', true);
$design = wc_get_order_item_meta($order_item_id, 'Дизайн', true);
$path = file_get_contents('
http://alasan.ru/wp-content/sert/?id=' . urlencode('#' . $order_id) . '&pr=' . $price . '&dsgn=' . $design);
$attachment_link = ABSPATH . $path;
wc_add_order_item_meta($order_item_id, 'Ссылка', '
http://alasan.ru/wp-content/sert/cache/sert_' . urlencode('%23' . $order_id). '.jpg', true);
$time = strtotime($date) - 10800; // Фикс для UTC Unix Timestamp
wp_schedule_single_event($time, 'send_certificate', array($mail, $attachment_link, $msg, $from));
} elseif ($name == 'Абонемент') {
$name = wc_get_order_item_meta($order_item_id, 'Имя', true);
$price = wc_get_order_item_meta($order_item_id, 'Номинал', true);
$mail = wc_get_order_item_meta($order_item_id, 'E-mail', true);
$path = file_get_contents('
http://alasan.ru/wp-content/sert/?id=' . urlencode('#' . $order_id) . '&pr=' . $price . '&dsgn=ticket');
$attachment_link = ABSPATH . $path;
wc_add_order_item_meta($order_item_id, 'Ссылка', '
http://alasan.ru/wp-content/sert/cache/sert_' . urlencode('%23' . $order_id) . '.jpg', true);
wp_schedule_single_event(time(), 'send_ticket', array($mail, $attachment_link, $name));
}
}
}
add_action('send_certificate', 'certificate_generation', 10, 3);
function certificate_generation($mail = "", $attachment_link = "", $buyer_message = "", $buyer_signature = "Не указано")
{
// Set content type html
add_filter('wp_mail_content_type', 'custom_wp_mail_content_type');
function custom_wp_mail_content_type()
{
return 'text/html';
}
$to = $mail;
$subject = 'Сертификат ';
$headers[] = 'From: Аляска <auto@alasan.ru>';
$headers[] = 'Bcc: alas@gmail.com';
$headers[] = 'Bcc: marketing@alasan.ru';
$message = '<html>';
$message .= '<head>';
$message .= '<title>' . $subject . '</title>';
$message .= '</head>';
$message .= '<body>';
$message .= '<div style="padding: 20px;background-color: #f3f3f3;border: 15px solid #7087ae;text-align: center;">';
$message .= '<p><img style="max-width: 100%" src="
http://alasan.ru/wp-content/themes/alyasa/assets/img/icons/logo.png"/></p>';
$message .= '<h3 style="font-size: 24px; line-height: 1; margin: 10px; margin-bottom: 20px; text-transform: uppercase; color: #7087ae;">' . $subject . '</h3>';
$message .= '<p>Сообщение отправителя</p>';
$message .= '<p>' . $buyer_message . '</p>';
$message .= '<p style=" text-align: right; font-style: italic; font-weight: 700; font-size: 18px; margin-bottom: 0; ">От: ' . $buyer_signature . '</p>';
$message .= '<p>Сертификат во вложении. Если его там не оказалось - пожалуйста, свяжитесь с нами.</p>';
$message .= '</body></html>';
$email = wp_mail($to, $subject, $message, $headers, $attachment_link);
// Reset content type html to avoid conflicts
remove_filter('wp_mail_content_type', 'custom_wp_mail_content_type');
return $email;
}
`
Письмо кому предназначался подарок не приходит.
Что не так делаю ?