-
Notifications
You must be signed in to change notification settings - Fork 1
/
footer_cart.php
181 lines (136 loc) · 6.02 KB
/
footer_cart.php
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<!-- Shopping Cart Modal -->
<div class="modal fade " id="shoppingCartModal" tabindex="-1" role="dialog" aria-labelledby="shoppingCartModalLabel">
<div class="modal-dialog modal-lg" role="document">
<div type="shop/checkout" template="modal" id="js-ajax-cart-checkout-process" class="no-settings"></div>
</div>
</div>
<script>
AddToCartModalContent = window.AddToCartModalContent || function (title) {
var html = ''
+ '<section style="text-align: center;">'
+ '<h5>' + title + '</h5>'
+ '<p><?php _ejs("has been added to your cart"); ?></p><br />'
+ '<div><a href="javascript:;" onclick="mw.dialog.get(\'#AddToCartModal\').remove()" class="pull-left mt-2"><?php _ejs("Continue shopping"); ?></a>'
+ '<a href="<?php print checkout_url(); ?>" class="btn-d pull-right"><?php _ejs("Checkout"); ?></a></section><div class="clearfix"></div></div>';
return html;
}
function cartModalBindButtons(step) {
$('.js-show-step').off('click');
$('.js-show-step').on('click', function () {
var has_error = 0;
var step = $(this).data('step');
if (step == 'payment-method') {
$('.js-delivery-address input').each(function () {
if (!this.checkValidity()) {
mw.notification.warning('<?php _e("Please fill the required fields"); ?>');
// ..alert($(this).prop('name') + ' is not valid');
$(this).addClass('error');
has_error = 1;
} else {
$(this).removeClass('error');
}
});
if (has_error) {
step = 'delivery-address'
}
}
$('.js-show-step').removeClass('active');
$('[data-step]').removeClass('active');
$('[data-step="' + step + '"]').addClass('active').parent().removeClass('muted');
step1 = '.js-' + step;
$('.js-step-content').hide();
$(step1).show();
$(this).addClass('active');
});
}
$(document).ready(function () {
mw.on('mw.cart.add', function (event, data) {
$("#shoppingCartModal").modal();
$("#js-ajax-cart-checkout-process").reload_module()
});
});
</script>
<script>
$(document).ready(function () {
$('#loginModal').on('show.bs.modal', function (e) {
$('#loginModalModuleLogin').reload_module();
$('#loginModalModuleRegister').reload_module();
});
$('#shoppingCartModal').on('show.bs.modal', function (e) {
$('#js-ajax-cart-checkout-process').reload_module();
});
mw.on('mw.cart.add', function (event, data) {
$('#shoppingCartModal').modal('show');
});
<?php if (isset($_GET['mw_payment_success'])) { ?>
$('#js-ajax-cart-checkout-process').attr('mw_payment_success', true);
$('#shoppingCartModal').modal('show')
<?php } ?>
$('body').on('click', '.js-show-register-window', function (e) {
$('#loginModal').modal('show');
$('.js-login-window').hide();
$('.js-register-window').show();
e.preventDefault();
e.stopPropagation();
});
$('.js-show-login-window').on('click', function (e) {
$('.js-register-window').hide();
$('.js-login-window').show();
e.preventDefault();
e.stopPropagation();
});
});
</script>
<?php if ($shopping_cart == 'true'): ?>
<script>
mw.require('shop.js');
</script>
<?php endif; ?>
<!-- Login Modal -->
<div class="modal login-modal" id="loginModal" tabindex="-1" role="dialog" aria-labelledby="loginModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-bs-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
</div>
<div class="modal-body">
<div class="js-login-window">
<!-- <div class="icon"><i class="material-icons">person</i></div>-->
<h2 class="text-center mb-5">Login</h2>
<div type="users/login" template="popup" id="loginModalModuleLogin"></div>
</div>
<div class="js-register-window" style="display:none;">
<!-- <div class="icon"><i class="material-icons">exit_to_app</i></div>-->
<h2 class="text-center mb-5">Register</h2>
<div type="users/register" id="loginModalModuleRegister"></div>
<p class="or"><span>or</span></p>
<div class="act login">
<a href="#" class="js-show-login-window"><span><?php _lang("Back to Login", "templates/shopmag") ?></span></a>
</div>
</div>
</div>
</div>
</div>
</div>
<?php if (user_id()): ?>
<script>
$(document).ready(function () {
$('#ordersModal').on('shown.bs.modal', function (e) {
mw.reload_module('#user_orders_modal')
});
});
</script>
<!-- Orders Modal -->
<div class="modal fade my-orders-modal" id="ordersModal" tabindex="-1" role="dialog" aria-labelledby="ordersModalLabel">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-bs-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
</div>
<div class="modal-body">
<div type="users/orders" id="user_orders_modal"></div>
</div>
</div>
</div>
</div>
<?php endif; ?>