2a050410
Yarik
Order
|
1
2
3
4
|
$(function() {
$(document)
.on('click', '.remove-order-product', function(e) {
e.preventDefault();
|
1821d077
Anastasia
change order price
|
5
|
var current_price = parseInt($(this).parents('.row-order-product').data('price'));
|
a55bed64
Anastasia
- order
|
6
7
|
console.log(current_price);
var number = parseInt($(this).parents('.row-order-product').children('.col-md-2').children('.form-group').children('input').val());
|
b6db17e5
Anastasia
order in admin
|
8
9
10
11
|
var id = $(this)
.data('id');
var variant = $(this)
.data('variant');
|
543a6adb
Anastasia
order
|
12
13
14
|
$(this)
.parents('.row-order-product')
.remove();
|
a55bed64
Anastasia
- order
|
15
16
|
var total_price = parseInt($("#total-sum").text());
console.log(total_price);
|
543a6adb
Anastasia
order
|
17
18
|
total_price = total_price - (current_price * number);
console.log(number);
|
a55bed64
Anastasia
- order
|
19
|
$("#total-sum").text(total_price);
|
2a050410
Yarik
Order
|
20
|
});
|
7f07c94f
Виталий
categories create
|
21
22
23
24
25
26
27
28
|
$('#count-to-order').keypress(function(e) {
if (!(e.which==8 ||(e.which>47 && e.which<58))) return false;
});
$('#count-to-order').change(function(e) {
if ($(this).val() <= 0) {
$(this).val('1')
}
});
|
fd40a9e1
Yarik
Products to order
|
29
30
31
32
33
34
35
|
$(document)
.on('click', '.variant-to-order', function(e) {
e.preventDefault();
var id = $('#add-to-order');
var count = $('#count-to-order');
var order = $(this)
.data('id');
|
7f07c94f
Виталий
categories create
|
36
37
38
39
40
41
42
43
44
|
if (id.val() ) {
if(count.val()<=0) {
var newCountVal = count.val();
} else {
var newCountVal = 1;
}
$('.order-goods-th').css({display:'block'});
|
fd40a9e1
Yarik
Products to order
|
45
46
|
$.post('/admin/order/add-to-order', {
id: id.val(),
|
7f07c94f
Виталий
categories create
|
47
|
count: newCountVal,
|
fd40a9e1
Yarik
Products to order
|
48
|
order: order
|
1228053e
Anastasia
event order
|
49
|
}, function(data) {
|
543a6adb
Anastasia
order
|
50
|
if (data.success) {
|
a55bed64
Anastasia
- order
|
51
52
53
|
var sum = $('#total-sum').text();
console.log(sum);
$('#total-sum')
|
8b638e12
Anastasia
sum in order
|
54
55
56
|
.html(parseInt(sum) + parseInt(data.price));
$('#product-rows')
.append(data.row);
|
7f07c94f
Виталий
categories create
|
57
|
$('#add-to-order').select2("val", "");
|
543a6adb
Anastasia
order
|
58
|
}
|
1228053e
Anastasia
event order
|
59
|
|
fd40a9e1
Yarik
Products to order
|
60
|
});
|
fd40a9e1
Yarik
Products to order
|
61
62
|
}
});
|
1821d077
Anastasia
change order price
|
63
64
|
$(document).on('change', '.count', function() {
var count_old = parseInt(this.defaultValue);
|
8b638e12
Anastasia
sum in order
|
65
|
console.log(count_old);
|
1821d077
Anastasia
change order price
|
66
67
|
var count_new = parseInt(this.value);
var current_price = parseInt($(this).parents('.row-order-product').data('price'));
|
a55bed64
Anastasia
- order
|
68
|
var total_price = parseInt($("#total-sum").text());
|
1821d077
Anastasia
change order price
|
69
70
|
total_price = total_price - (count_old * current_price) + (count_new * current_price);
this.defaultValue = this.value;
|
a55bed64
Anastasia
- order
|
71
|
$("#total-sum").text(total_price);
|
1821d077
Anastasia
change order price
|
72
|
})
|
fd40a9e1
Yarik
Products to order
|
73
74
75
76
77
|
});
function showLoader(container) {
$(container)
.prepend('<div class="loader-wrapper"></div>');
}
|