2a050410
Yarik
Order
|
1
2
3
4
|
$(function() {
$(document)
.on('click', '.remove-order-product', function(e) {
e.preventDefault();
|
1821d077
Anastasia
change order price
|
5
6
|
var current_price = parseInt($(this).parents('.row-order-product').data('price'));
var number = parseInt($(this).parents('.row-order-product').children('.col-md-3').children('.form-group').children('input').val());
|
2a050410
Yarik
Order
|
7
8
9
|
$(this)
.parents('.row-order-product')
.remove();
|
1821d077
Anastasia
change order price
|
10
11
12
13
|
var total_price = parseInt($(".sum_all").children('p').text());
total_price = total_price - (current_price * number);
console.log(number);
$(".sum_all").children('p').text(total_price);
|
2a050410
Yarik
Order
|
14
|
});
|
fd40a9e1
Yarik
Products to order
|
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
$(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');
if (id.val() && count.val()) {
var selector = '#order-product-pjax';
showLoader(selector);
$.post('/admin/order/add-to-order', {
id: id.val(),
count: count.val(),
order: order
|
1228053e
Anastasia
event order
|
29
|
}, function(data) {
|
fd40a9e1
Yarik
Products to order
|
30
31
32
33
|
$.pjax.reload(selector, {
timeout: 5000,
fragment: selector
});
|
1228053e
Anastasia
event order
|
34
35
36
37
|
var sum = $(".sum_all").children('p').text();
$(".sum_all").children('p').html(parseInt(sum)+parseInt(data));
|
fd40a9e1
Yarik
Products to order
|
38
39
40
41
42
43
44
|
});
id.val(null)
.trigger('change');
count.val(null)
.trigger('change');
}
});
|
1821d077
Anastasia
change order price
|
45
46
47
48
49
50
51
52
53
|
$(document).on('change', '.count', function() {
var count_old = parseInt(this.defaultValue);
var count_new = parseInt(this.value);
var current_price = parseInt($(this).parents('.row-order-product').data('price'));
var total_price = parseInt($(".sum_all").children('p').text());
total_price = total_price - (count_old * current_price) + (count_new * current_price);
this.defaultValue = this.value;
$(".sum_all").children('p').text(total_price);
})
|
fd40a9e1
Yarik
Products to order
|
54
55
56
57
58
|
});
function showLoader(container) {
$(container)
.prepend('<div class="loader-wrapper"></div>');
}
|