Не могли бы вы подсказать.
Я добавил поля "количество" и "почта".
Но в поле количество есть баг, если цифра меньше четырех символов, то письмо не отправляется.
Может кто знает как исправить, мне нужно чтобы можно было заказать и 1 и 100 и т.п.
JS:
$(document).ready(function () { $('#fast_order').colorbox({href:"#fast_order_form",inline:true, width:"650px", height:"390px", title:" "}); $('#fast_order_form .fast_order_center button').click(function () { var product_name = $('#product_name').val(); var product_price = $('#product_price').val(); var customer_name = $('#customer_name').val(); var customer_phone = $('#customer_phone').val(); var customer_email = $('#customer_email').val(); var customer_kolichestvo = $('#customer_kolichestvo').val(); var customer_message = $('#customer_message').val(); $('#result').html('Обрабатываем введенные данные..'); $.post('http://mad-creation.ru/fast_order.php', { 'product_name': product_name, 'product_price': product_price, 'customer_name': customer_name, 'customer_phone': customer_phone, 'customer_email': customer_email, 'customer_kolichestvo': customer_kolichestvo, 'customer_message': customer_message }, function (data) { if (data == 'empty') { $('#fast_order_result').html('<span class="fast_order_error">Обязательно укажите ваше имя и телефон, иначе мы не сможем вам перезвонить!</span>'); } else { $('#fast_order_result').html('<span class="fast_order_success">Ваш заказ успешно оформлен!</span><br /><span>Мы перезвоним вам в течение дня. <a onclick="$(window).colorbox.close();">Закрыть</a> это окно?</span>'); } }); });});
PHP:
<?php $product_name = trim($_POST['product_name']); $product_price = trim($_POST['product_price']); $customer_name = trim($_POST['customer_name']); $customer_phone = trim($_POST['customer_phone']); $customer_email = trim($_POST['customer_email']); $customer_kolichestvo = trim($_POST['customer_kolichestvo']); $customer_message = trim($_POST['customer_message']); $mail_subject = "Мой интернет-магазин - быстрый заказ (".date('d.m.Y H:i').")"; if (isset($customer_name) && $customer_name!=="" && isset($customer_phone) && $customer_phone!=="") { $store_email = "почта"; $fast_order_email = "почта"; $product_name = iconv("UTF-8", "windows-1251", $product_name); $product_price = iconv("UTF-8", "windows-1251", $product_price); $subject = '=?windows-1251?B?'.base64_encode($mail_subject).'?='; $customer_name = iconv("UTF-8", "windows-1251", $customer_name); $customer_phone = iconv("UTF-8", "windows-1251", $customer_phone); $customer_email = iconv("UTF-8", "windows-1251", $customer_email); $customer_kolichestvo = iconv("UTF-8", "windows-1251", $customer_kolichestvo); $customer_message = iconv("UTF-8", "windows-1251", $customer_message); $subject = '=?windows-1251?B?'.base64_encode($mail_subject).'?='; $headers = "From: <".$fast_order_email.">\r\n"; $headers = $headers."Return-path: <".$fast_order_email.">\r\n"; $headers = $headers."Content-type: text/plain; charset=\"windows-1251\"\r"; mail($store_email,$mail_subject,"Быстрый заказ\n\nДата заказа: ".date('d.m.Y H:i')."\nЗаказчик: ".$customer_name."\nТелефон: ".$customer_phone."\nПочта: ".$customer_email."\nКоличество: ".$customer_kolichestvo."\nКомментарий: ".$customer_message."\n\nТовар: ".$product_name."\nЦена: ".$product_price,$headers); } else { echo "empty"; };