order.js 1.34 KB
$(
    function() {
        $(document)
            .on(
                'click', '.remove-order-product', function(e) {
                    e.preventDefault();
                    $(this)
                        .parents('.row-order-product')
                        .remove();
                }
            );
        $(document)
            .on(
                'click', '.variant-to-order', function(e) {
                    e.preventDefault();
                    var id = $('#add-to-order');
                    var count = $('#count-to-order');
                    if (id.val()) {
                        $.ajax(
                            {
                                url: '/admin/order/add-to-order',
                                type: "POST",
                                data: {
                                    'id': id.val(),
                                    'count': count.val()
                                },
                                success: function(data) {
                                    if (data.success) {
                                        $('#product-rows')
                                            .append(data.row);
                                    }
                                }
                            }
                        );
                    }
                }
            );
    }
);