A
A
Anton2015-11-20 17:55:13
Kohana
Anton, 2015-11-20 17:55:13

When ordering a product, an order letter goes to the admin, how to add it to go to the client?

Hello, in the cart template where are the user's orders and also the fields with ordering, phone, email, etc.
Everything is wrapped in:

<form action="cart/make_order" method="POST" id="sumbitForm">
Тут товары, цена и т.д, поля телефон, емаил и т.д
</form>

When you click on the button to place an order, it is sent to the action cart/make_order and the letter about the order goes to the admin.
I made one more action, cart/make_orderclient
How can I add it so that when ordering, the letter goes in the same way to the admin and + to the client.
To the client on the email that he fills in the field, and this: In general, I want to implement sending a letter to the client when ordering goods. There is js in the basket file template, there is a check for filling fields, etc., I just don’t know how to attach two actions correctly, because you can remove it from the form and add it to js
<?=$user->email)?>


<script type="text/javascript">
jQuery("#makeorder").live("click", function () {

            jQuery('#resultred').html('');

            name = jQuery("#name").val();
            if (name == '') {
                jQuery('#resultred').addClass('resultred').html('Введите ФИО');
                return false;
            }

            phone = jQuery("#phone").val();
            if (phone == '') {
                jQuery('#resultred').addClass('resultred').html('Введите контактный телефон');
                return false;
            }
            else if (phone != '') {
                var patt = /^((8|\+7)[\- ]?)?(\(?\d{3}\)?[\- ]?)?[\d\- ]{7,10}$/;
                var res = patt.test(phone);
                if (res == false) {
                    jQuery('#resultred').addClass('resultred').html('Введите корректный контактный телефон, ( пример 89084483733 )');
                    return false;
                }
            }

            email = jQuery("#email").val();
            if (email == '') {
                jQuery('#resultred').addClass('resultred').html('Введите E-mail');
                return false;
            }

            city = jQuery("#city").val();
            if (city == '') {
                jQuery('#resultred').addClass('resultred').html('Введите город');
                return false;
            }

            if (jQuery("input[name=delivery]").is(':checked') == false) {
                jQuery('#resultred').addClass('resultred').html('Виберите метод доставки');
                return false;
            }

            if (jQuery("input[name=payment_method]").is(':checked') == false) {
                jQuery('#resultred').addClass('resultred').html('Виберите метод оплаты');
                return false;
            }

            var data = {};
            data.capcha = jQuery("#captcha_cart").val();
            if (data.capcha == "") {
                jQuery('#resultred').addClass('resultred').html('Неправильно ввели код с картинки, повторите ввод кода с картинки');
                return false;
            }
            if (data.capcha != "") {

                jQuery.ajax({
                    url: 'http://' + location.host + '/ajax/valid_captcha/',
                    type: 'POST',
                    dataType: 'json',
                    data: {data: data},
                    success: function (data) {

                        if (data == 'error_captcha') {
                            $('#resultred').addClass('resultred').html('Неправильно ввели код с картинки, повторите ввод кода с картинки');
                            return false;
                        }
                        else {
                            $('#result').html('');
                            jQuery("#sumbitForm").submit();
                        }
                    }
                });
            }
            return false;
        });
    });
</script>

As I understand it, js is built like this, there is a validation check if everything is ok, if the check passes validation, then the id is accessed which is in the form and then the action is triggered to send the order.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Michael, 2015-11-20
@scherbuk

add mail() to cart/make_order
or after jQuery("#sumbitForm").submit(); add another ajax to your action

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question