-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
106 lines (94 loc) · 3.68 KB
/
index.js
1
2
3
4
5
6
7
8
9
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
$(document).ready(function(){
$("#banner-area .owl-carousel").owlCarousel({ // it is banner owl carousel
dots: true,
items: 1
});
$("#top-sale .owl-carousel").owlCarousel({ // it is top sales (owl carousel)
dots: false,
loop: true,
nav: true,
responsive : {
0: {
items: 1
},
600: {
items: 3
},
1000 : {
items: 5
}
}
});
var $grid = $(".grid").isotope({ // isotope filters
itemSelector : '.grid-item',
layoutMode : 'fitRows'
});
$(".button-group").on("click", "button", function(){ // it is filter items on button
var filterValue = $(this).attr('data-filter');
$grid.isotope({ filter: filterValue});
})
$("#new-phones .owl-carousel").owlCarousel({ // it is new laptops via owl carousel
nav: false,
loop: true,
dots: true,
responsive : {
0: {
items: 1
},
600: {
items: 3
},
1000 : {
items: 5
}
}
});
$("#blogs .owl-carousel").owlCarousel({ // it is blog via owl carousel
dots: true,
loop: true,
nav: false,
responsive : {
0: {
items: 1
},
600: {
items: 3
}
}
})
let $qty_up = $(".qty .qty-up"); // it is product via qty section
let $qty_down = $(".qty .qty-down");
let $deal_price = $("#deal-price");
$qty_up.click(function(e){ // it is click on qty up
let $input = $(`.qty_input[data-id='${$(this).data("id")}']`);
let $price = $(`.product_price[data-id='${$(this).data("id")}']`);
$.ajax({url: "template/ajax.php", type : 'post', data : { itemid : $(this).data("id")}, success: function(result){
let obj = JSON.parse(result); // it is change product price via ajax call
let item_price = obj[0]['item_price'];
if($input.val() >= 1 && $input.val() <= 9){
$input.val(function(i, oldval){
return ++oldval;
});
$price.text(parseInt(item_price * $input.val()).toFixed(2));// increasing price
let subtotal = parseInt($deal_price.text()) + parseInt(item_price); // subtotal price
$deal_price.text(subtotal.toFixed(2));
}
}}); //close ajax request
}); //close qty up
$qty_down.click(function(e){ // it is click on qty down
let $input = $(`.qty_input[data-id='${$(this).data("id")}']`);
let $price = $(`.product_price[data-id='${$(this).data("id")}']`);
$.ajax({url: "template/ajax.php", type : 'post', data : { itemid : $(this).data("id")}, success: function(result){
let obj = JSON.parse(result); // it is change product price via ajax call
let item_price = obj[0]['item_price'];
if($input.val() > 1 && $input.val() <= 10){
$input.val(function(i, oldval){
return --oldval;
});
$price.text(parseInt(item_price * $input.val()).toFixed(2)); // it is increasing price of the product
let subtotal = parseInt($deal_price.text()) - parseInt(item_price); // set subtotal price
$deal_price.text(subtotal.toFixed(2));
}
}}); //close ajax request
}); //close qty down button
});