ecommerce.js
1.71 KB
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
var sfw;
function cartWizard(){
sfw = $(".wizard-validation").stepFormWizard({
height: "auto",
theme: 'sky',
rtl: $('body').hasClass('rtl') ? true : false,
finishBtn: $('<input class="finish-btn sf-right sf-btn" type="submit" value="Confirm Payment"/>'),
onNext: function(i, wizard) {
return $('.wizard-validation', wizard).parsley().validate('block' + i);
},
onFinish: function(i, wizard) {
return $('.wizard-validation', wizard).parsley().validate();
}
});
}
$(document).ready(function() {
setTimeout(function(){
cartWizard();
},100);
$('.wizard-validation').on('click', '.sf-btn', function(){
setTimeout(function () {
$(window).resize();
$(window).trigger('resize');
}, 0);
});
/* Remove Elements */
$(".shopping-cart-table .icons-office-52").on('click', function(){
$(this).closest('tr').fadeOut(200, function(){
$(this).closest('tr').remove();
var total = 0;
$('.item-total').each(function(){
total += +($(this).text());
});
$('.total p').text(total+'.00');
});
});
/* Update total on quantity change */
$(".shopping-cart-table .quantity").on('change', function(){
var quantity = $(this).val();
var itemPrice = $(this).closest('tr').find('.item-price').text();
var itemTotal = quantity * itemPrice;
$(this).closest('tr').find('.item-total').text(itemTotal+'.00');
var total = 0;
$('.item-total').each(function(){
total += +($(this).text());
});
$('.total p').text(total+'.00');
});
});