- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
function order_to() {
    jQuery.ajax({
        type: "POST",
        url: url+'/saveMethod/',
        data: {
            "method": "guest"
        },
        success: function(success) {
            console.log(success);
            jQuery.ajax({
                type: "POST",
                url: url+'/saveBilling/',
                data: {
                    "billing[address_id]": "",
                    "billing[firstname]": "Test",
                    "billing[lastname]": "Query",
                    "billing[company]": "",
                    "billing[email]": "[email protected]",
                    "billing[street][]": "Street",
                    "billing[city]": "City",
                    "billing[region_id]": "",
                    "billing[region]": "",
                    "billing[postcode]": "50",
                    "billing[country_id]": "UA",
                    "billing[telephone]": "+100500",
                    "billing[fax]": "",
                    "billing[customer_password]": "",
                    "billing[confirm_password]": "",
                    "billing[save_in_address_book]": "1",
                    "billing[use_for_shipping]": "1"
                },
                success: function(success) {
                    console.log(success);
                    jQuery.ajax({
                        type: "POST",
                        url: url+'/saveShippingMethod/',
                        data: {
                            "shipping_method": "flatrate_flatrate"
                        },
                        success: function(success) {
                            console.log(success);
                            jQuery.ajax({
                                type: "POST",
                                url: url+'/savePayment/',
                                data: {
                                    "payment[method]": "checkmo"
                                },
                                success: function(success) {
                                    console.log(success);
                                    var reg = /\/form_key\/(.*?)\/\'\)/;
                                    var raw = jQuery('button.button.btn-cart').attr('onclick');
                                    if (raw == undefined) {
                                        key_form = jQuery('form input[name=form_key]').val();
                                    } else {
                                        var key_form = reg.exec(raw)[1];
                                    };
                                    console.log(key_form);
                                    jQuery.ajax({
                                        type: "POST",
                                        url: url+'/saveOrder/form_key/' + key_form + '/',
                                        data: {
                                            "payment[method]": "checkmo"
                                        },
                                        success: function(success) {
                                            console.log(success);
                                        }
                                    });
                                }
                            });
                        }
                    });
                }
            });
        }
    });
}
order_to();
order_to();
                                     
        
            Каскадный запрос на jQuery на подтверждение заказа в Magento загнан в функцию и вызывается два раза, потому что с первого не проходит. А еще в одном блоке токен получается из артибута узла через регулярку...