Version Description
Release Date - 18 October 2022
- WooCommerce 7.0 support
- Updated integration with the WooCommerce TM Extra Product Options plugin
- Improved frontend AJAX routine
- Fixed URL rewrites issue
Download this release
Release Info
Developer | templateinvaders |
Plugin | WooCommerce Wishlist Plugin |
Version | 2.0.7 |
Comparing to | |
See all releases |
Code changes from version 2.0.6 to 2.0.7
- assets/css/admin-form-rtl.min.css +1 -1
- assets/css/admin-form.min.css +1 -1
- assets/css/admin-rtl.min.css +1 -1
- assets/css/admin-setup-rtl.min.css +1 -1
- assets/css/admin-setup.min.css +1 -1
- assets/css/admin.min.css +1 -1
- assets/css/public-rtl.min.css +1 -1
- assets/css/public.min.css +1 -1
- assets/css/theme-rtl.min.css +1 -1
- assets/css/theme.min.css +1 -1
- assets/css/webfont-rtl.min.css +1 -1
- assets/css/webfont.min.css +1 -1
- assets/js/admin.js +67 -130
- assets/js/admin.min.js +1 -1
- assets/js/public.js +148 -296
- assets/js/public.min.js +2 -2
- includes/api/ajax.php +0 -284
- includes/api/yoasti18n/i18n-module-wordpressorg.php +74 -74
- includes/wishlist.class.php +10 -0
- integrations/woocommerce-tm-extra-product-options.php +149 -137
- languages/ti-woocommerce-wishlist.pot +20 -20
- public/addtowishlist.class.php +11 -1
- public/tinvwl.class.php +4 -12
- public/wishlist/ajax.class.php +28 -29
- public/wishlist/buttons.class.php +3 -2
- readme.txt +9 -1
- templates/ti-wishlist-empty.php +7 -7
- ti-woocommerce-wishlist.php +3 -3
- tinv-wishlists-function.php +1 -1
assets/css/admin-form-rtl.min.css
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
/**
|
2 |
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
-
* @version 2.0.
|
4 |
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
*/
|
6 |
.tiwlform-number-container{display:inline-block;margin:2px;position:relative;vertical-align:middle}
|
1 |
/**
|
2 |
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
+
* @version 2.0.7
|
4 |
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
*/
|
6 |
.tiwlform-number-container{display:inline-block;margin:2px;position:relative;vertical-align:middle}
|
assets/css/admin-form.min.css
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
/**
|
2 |
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
-
* @version 2.0.
|
4 |
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
*/
|
6 |
.tiwlform-number-container{display:inline-block;margin:2px;position:relative;vertical-align:middle}
|
1 |
/**
|
2 |
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
+
* @version 2.0.7
|
4 |
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
*/
|
6 |
.tiwlform-number-container{display:inline-block;margin:2px;position:relative;vertical-align:middle}
|
assets/css/admin-rtl.min.css
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
/**
|
2 |
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
-
* @version 2.0.
|
4 |
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
*/
|
6 |
*{-webkit-box-sizing:border-box;box-sizing:border-box}
|
1 |
/**
|
2 |
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
+
* @version 2.0.7
|
4 |
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
*/
|
6 |
*{-webkit-box-sizing:border-box;box-sizing:border-box}
|
assets/css/admin-setup-rtl.min.css
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
/**
|
2 |
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
-
* @version 2.0.
|
4 |
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
*/
|
6 |
html{background:#f6f3ed}
|
1 |
/**
|
2 |
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
+
* @version 2.0.7
|
4 |
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
*/
|
6 |
html{background:#f6f3ed}
|
assets/css/admin-setup.min.css
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
/**
|
2 |
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
-
* @version 2.0.
|
4 |
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
*/
|
6 |
html{background:#f6f3ed}
|
1 |
/**
|
2 |
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
+
* @version 2.0.7
|
4 |
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
*/
|
6 |
html{background:#f6f3ed}
|
assets/css/admin.min.css
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
/**
|
2 |
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
-
* @version 2.0.
|
4 |
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
*/
|
6 |
*{-webkit-box-sizing:border-box;box-sizing:border-box}
|
1 |
/**
|
2 |
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
+
* @version 2.0.7
|
4 |
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
*/
|
6 |
*{-webkit-box-sizing:border-box;box-sizing:border-box}
|
assets/css/public-rtl.min.css
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
/**
|
2 |
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
-
* @version 2.0.
|
4 |
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
*/
|
6 |
.tinv-wishlist form,.tinv-wishlist p:last-child,.tinv-wishlist table{margin-bottom:0}
|
1 |
/**
|
2 |
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
+
* @version 2.0.7
|
4 |
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
*/
|
6 |
.tinv-wishlist form,.tinv-wishlist p:last-child,.tinv-wishlist table{margin-bottom:0}
|
assets/css/public.min.css
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
/**
|
2 |
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
-
* @version 2.0.
|
4 |
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
*/
|
6 |
.tinv-wishlist form,.tinv-wishlist p:last-child,.tinv-wishlist table{margin-bottom:0}
|
1 |
/**
|
2 |
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
+
* @version 2.0.7
|
4 |
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
*/
|
6 |
.tinv-wishlist form,.tinv-wishlist p:last-child,.tinv-wishlist table{margin-bottom:0}
|
assets/css/theme-rtl.min.css
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
/**
|
2 |
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
-
* @version 2.0.
|
4 |
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
*/
|
6 |
.tinv-wishlist,.tinv-wishlist input,.tinv-wishlist select,.tinv-wishlist textarea,.tinv-wishlist button,.tinv-wishlist input[type=button],.tinv-wishlist input[type=reset],.tinv-wishlist input[type=submit]{font-family:Georgia,serif;font-size:14px;font-weight:400;text-transform:none;line-height:1.75}
|
1 |
/**
|
2 |
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
+
* @version 2.0.7
|
4 |
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
*/
|
6 |
.tinv-wishlist,.tinv-wishlist input,.tinv-wishlist select,.tinv-wishlist textarea,.tinv-wishlist button,.tinv-wishlist input[type=button],.tinv-wishlist input[type=reset],.tinv-wishlist input[type=submit]{font-family:Georgia,serif;font-size:14px;font-weight:400;text-transform:none;line-height:1.75}
|
assets/css/theme.min.css
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
/**
|
2 |
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
-
* @version 2.0.
|
4 |
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
*/
|
6 |
.tinv-wishlist,.tinv-wishlist input,.tinv-wishlist select,.tinv-wishlist textarea,.tinv-wishlist button,.tinv-wishlist input[type=button],.tinv-wishlist input[type=reset],.tinv-wishlist input[type=submit]{font-family:Georgia,serif;font-size:14px;font-weight:400;text-transform:none;line-height:1.75}
|
1 |
/**
|
2 |
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
+
* @version 2.0.7
|
4 |
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
*/
|
6 |
.tinv-wishlist,.tinv-wishlist input,.tinv-wishlist select,.tinv-wishlist textarea,.tinv-wishlist button,.tinv-wishlist input[type=button],.tinv-wishlist input[type=reset],.tinv-wishlist input[type=submit]{font-family:Georgia,serif;font-size:14px;font-weight:400;text-transform:none;line-height:1.75}
|
assets/css/webfont-rtl.min.css
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
/**
|
2 |
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
-
* @version 2.0.
|
4 |
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
*/
|
6 |
@font-face{font-family:"tinvwl-webfont";font-display:block;src:url("../fonts/tinvwl-webfont.eot?ver=xu2uyi");src:url("../fonts/tinvwl-webfont.eot?ver=xu2uyi#iefix") format("embedded-opentype"),url("../fonts/tinvwl-webfont.woff2?ver=xu2uyi") format("woff2"),url("../fonts/tinvwl-webfont.woff?ver=xu2uyi") format("woff"),url("../fonts/tinvwl-webfont.ttf?ver=xu2uyi") format("truetype"),url("../fonts/tinvwl-webfont.svg?ver=xu2uyi#tinvwl-webfont") format("svg");font-weight:normal;font-style:normal}
|
1 |
/**
|
2 |
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
+
* @version 2.0.7
|
4 |
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
*/
|
6 |
@font-face{font-family:"tinvwl-webfont";font-display:block;src:url("../fonts/tinvwl-webfont.eot?ver=xu2uyi");src:url("../fonts/tinvwl-webfont.eot?ver=xu2uyi#iefix") format("embedded-opentype"),url("../fonts/tinvwl-webfont.woff2?ver=xu2uyi") format("woff2"),url("../fonts/tinvwl-webfont.woff?ver=xu2uyi") format("woff"),url("../fonts/tinvwl-webfont.ttf?ver=xu2uyi") format("truetype"),url("../fonts/tinvwl-webfont.svg?ver=xu2uyi#tinvwl-webfont") format("svg");font-weight:normal;font-style:normal}
|
assets/css/webfont.min.css
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
/**
|
2 |
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
-
* @version 2.0.
|
4 |
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
*/
|
6 |
@font-face{font-family:"tinvwl-webfont";font-display:block;src:url("../fonts/tinvwl-webfont.eot?ver=xu2uyi");src:url("../fonts/tinvwl-webfont.eot?ver=xu2uyi#iefix") format("embedded-opentype"),url("../fonts/tinvwl-webfont.woff2?ver=xu2uyi") format("woff2"),url("../fonts/tinvwl-webfont.woff?ver=xu2uyi") format("woff"),url("../fonts/tinvwl-webfont.ttf?ver=xu2uyi") format("truetype"),url("../fonts/tinvwl-webfont.svg?ver=xu2uyi#tinvwl-webfont") format("svg");font-weight:normal;font-style:normal}
|
1 |
/**
|
2 |
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
+
* @version 2.0.7
|
4 |
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
*/
|
6 |
@font-face{font-family:"tinvwl-webfont";font-display:block;src:url("../fonts/tinvwl-webfont.eot?ver=xu2uyi");src:url("../fonts/tinvwl-webfont.eot?ver=xu2uyi#iefix") format("embedded-opentype"),url("../fonts/tinvwl-webfont.woff2?ver=xu2uyi") format("woff2"),url("../fonts/tinvwl-webfont.woff?ver=xu2uyi") format("woff"),url("../fonts/tinvwl-webfont.ttf?ver=xu2uyi") format("truetype"),url("../fonts/tinvwl-webfont.svg?ver=xu2uyi#tinvwl-webfont") format("svg");font-weight:normal;font-style:normal}
|
assets/js/admin.js
CHANGED
@@ -5,55 +5,42 @@ function TInvWL($, h) {
|
|
5 |
this.g = '_';
|
6 |
this.ho = h || false;
|
7 |
this.n = 'TInvWL';
|
8 |
-
|
9 |
this.aj_act = function (a) {
|
10 |
return [this.pf, a].join(this.g);
|
11 |
};
|
12 |
-
|
13 |
this._csel = function (a, b) {
|
14 |
var b = b || '.';
|
15 |
return '{0}{1}{2}'.format(b, this.pf, a);
|
16 |
};
|
17 |
-
|
18 |
this._tm = function (a) {
|
19 |
var c = $('script#{0}[type=\'text/template\']'.format(a));
|
20 |
-
|
21 |
if (c.length) {
|
22 |
return c.html();
|
23 |
}
|
24 |
-
|
25 |
return '';
|
26 |
};
|
27 |
-
|
28 |
this.formElm = function () {
|
29 |
$(this._csel('-form-onoff')).tiwl_onoff();
|
30 |
$('input[type=checkbox][tiwl-show], input[type=checkbox][tiwl-hide]').tiwl_onoffblock();
|
31 |
$('[tiwl-value][tiwl-show], [tiwl-value][tiwl-hide]').tiwl_byvalueblock();
|
32 |
-
|
33 |
if ('undefined' !== typeof $.fn.wpColorPicker) {
|
34 |
var calcLuminance = function calcLuminance(rgb) {
|
35 |
var c = rgb.substring(1);
|
36 |
-
|
37 |
var _rgb = parseInt(c, 16);
|
38 |
-
|
39 |
var r = _rgb >> 16 & 0xff;
|
40 |
var g = _rgb >> 8 & 0xff;
|
41 |
var b = _rgb >> 0 & 0xff;
|
42 |
return 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
43 |
};
|
44 |
-
|
45 |
var formColor = this._csel('-form-color');
|
46 |
-
|
47 |
$(formColor).each(function () {
|
48 |
var picker = $(this);
|
49 |
var pickerWrap = $(this).closest('.tinvwl-color-picker');
|
50 |
var eyedropper = pickerWrap.find('.tinvwl-eyedropper');
|
51 |
picker.css('background-color', picker.val());
|
52 |
-
|
53 |
if (175 < calcLuminance(picker.val())) {
|
54 |
picker.css('color', '#000000');
|
55 |
}
|
56 |
-
|
57 |
picker.iris({
|
58 |
mode: 'hsv',
|
59 |
target: $(this).parent().parent(),
|
@@ -63,7 +50,6 @@ function TInvWL($, h) {
|
|
63 |
} else {
|
64 |
$(this).css('color', '');
|
65 |
}
|
66 |
-
|
67 |
$(this).css('background-color', ui.color.toCSS());
|
68 |
}
|
69 |
});
|
@@ -88,50 +74,41 @@ function TInvWL($, h) {
|
|
88 |
});
|
89 |
}
|
90 |
};
|
91 |
-
|
92 |
this.wizard_page = function (a) {
|
93 |
$(a).find('select').change(this._wizard_page_ch);
|
94 |
this.wizard_page_ch($(a).find('select'));
|
95 |
};
|
96 |
-
|
97 |
this.wizard_page_ch = function (a) {
|
98 |
var a = $(a),
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
if ('' === a.val()) {
|
105 |
if (0 == c) {
|
106 |
b.addClass('tinvwl-error');
|
107 |
d.show();
|
108 |
e.show();
|
109 |
}
|
110 |
-
|
111 |
return;
|
112 |
}
|
113 |
-
|
114 |
b.removeClass('tinvwl-error');
|
115 |
d.hide();
|
116 |
e.hide();
|
117 |
};
|
118 |
-
|
119 |
this.pageElm = function () {
|
120 |
$(this._csel('-header', 'div.')).prependTo('#wpbody-content');
|
121 |
$(this._csel('-page-select')).each(this._wizard_page);
|
122 |
$('.bulkactions [type=submit]').each(this._control_bulkactions);
|
123 |
$('.action-search [type=submit]').each(this._control_search);
|
124 |
};
|
125 |
-
|
126 |
this.control_bulkactions = function (a) {
|
127 |
$(a).on('click', this._control_bulkactions_ck);
|
128 |
};
|
129 |
-
|
130 |
this.control_bulkactions_ck = function (a, b) {
|
131 |
var a = $(a),
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
if (c) {
|
136 |
if ('-1' === c.val()) {
|
137 |
b.preventDefault();
|
@@ -142,40 +119,31 @@ function TInvWL($, h) {
|
|
142 |
}
|
143 |
}
|
144 |
};
|
145 |
-
|
146 |
this.control_search = function (a) {
|
147 |
$(a).on('click', this._control_search_ck);
|
148 |
};
|
149 |
-
|
150 |
this.control_search_ck = function (a, b) {
|
151 |
var a = $(a),
|
152 |
-
|
153 |
-
|
154 |
if (c) {
|
155 |
if ('' === c.val()) {
|
156 |
b.preventDefault();
|
157 |
}
|
158 |
}
|
159 |
};
|
160 |
-
|
161 |
this.Run = function () {
|
162 |
this.formElm();
|
163 |
this.pageElm();
|
164 |
};
|
165 |
-
|
166 |
this.cg = function () {
|
167 |
var n = this.n;
|
168 |
-
|
169 |
if (this.ho) {
|
170 |
var t = new Date();
|
171 |
n = n + t.getFullYear() + t.getMonth() + t.getDate();
|
172 |
}
|
173 |
-
|
174 |
window[n] = this;
|
175 |
};
|
176 |
-
|
177 |
this.cg();
|
178 |
-
|
179 |
if (!String.prototype.format) {
|
180 |
String.prototype.format = function () {
|
181 |
var args = arguments;
|
@@ -184,16 +152,13 @@ function TInvWL($, h) {
|
|
184 |
});
|
185 |
};
|
186 |
}
|
187 |
-
|
188 |
(function (o) {
|
189 |
var n = o.n,
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
if (ho) {
|
194 |
c = 't=new Date(),n=n+t.getFullYear()+t.getMonth()+t.getDate(),';
|
195 |
}
|
196 |
-
|
197 |
for (var i in o) {
|
198 |
if ('function' === typeof o[i] && '_' !== i[0] && !o.hasOwnProperty('_' + i)) {
|
199 |
eval('o._' + i + '=function(a,b,c,d){var n=\'' + n + '\',' + c + 'o=window[n]||null;if (o) {return o.' + i + '(this,a,b,c,d);};};');
|
@@ -201,41 +166,36 @@ function TInvWL($, h) {
|
|
201 |
}
|
202 |
})(this);
|
203 |
}
|
204 |
-
|
205 |
(function ($) {
|
206 |
$.fn.tiwl_onoff = function (so) {
|
207 |
var sd = {
|
208 |
-
|
209 |
-
|
210 |
-
|
|
|
|
|
|
|
|
|
211 |
},
|
212 |
-
|
213 |
-
wrap: 'container',
|
214 |
-
button: 'button'
|
215 |
-
},
|
216 |
-
s = $.extend(true, {}, sd, so);
|
217 |
return $(this).each(function () {
|
218 |
var a = $(this),
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
if (!a.is('input')) {
|
229 |
return a;
|
230 |
}
|
231 |
-
|
232 |
d1.attr('class', d1.attr('class') + ' ' + a.attr('class'));
|
233 |
-
|
234 |
if (a.is(':disabled')) {
|
235 |
d1.toggleClass('disabled', a.is(':disabled'));
|
236 |
a.prop('disabled', false);
|
237 |
}
|
238 |
-
|
239 |
d1.toggleClass('checked', a.is(':checked'));
|
240 |
a.hide().removeAttr('class').wrap(d1).before(b1);
|
241 |
d1 = a.parent();
|
@@ -243,14 +203,12 @@ function TInvWL($, h) {
|
|
243 |
if (d1.hasClass('disabled')) {
|
244 |
return e.preventDefault();
|
245 |
}
|
246 |
-
|
247 |
d1.toggleClass('checked', $(this).is(':checked'));
|
248 |
});
|
249 |
d1.on('click', function (e) {
|
250 |
if (d1.hasClass('disabled')) {
|
251 |
return e.preventDefault();
|
252 |
}
|
253 |
-
|
254 |
if (a.is(':enabled') && d1.hasClass('checked') === a.is(':checked')) {
|
255 |
a.click();
|
256 |
}
|
@@ -258,119 +216,101 @@ function TInvWL($, h) {
|
|
258 |
return a;
|
259 |
});
|
260 |
};
|
261 |
-
|
262 |
$.fn.tiwl_onoffblock = function (so) {
|
263 |
var sd = {
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
return $(this).each(function () {
|
271 |
var a = $(this),
|
272 |
-
|
273 |
-
|
274 |
o_show = o.attr('tiwl-show'),
|
275 |
o_hide = o.attr('tiwl-hide'),
|
276 |
o_ch = s.isChecked.call(o),
|
277 |
doAction = function doAction(o_, on) {
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
282 |
};
|
283 |
-
|
284 |
-
if ('string' === typeof o_show) {
|
285 |
-
doAction(o_show, o_ch);
|
286 |
-
}
|
287 |
-
|
288 |
-
if ('string' === typeof o_hide) {
|
289 |
-
doAction(o_hide, !o_ch);
|
290 |
-
}
|
291 |
-
|
292 |
-
return o;
|
293 |
-
};
|
294 |
-
|
295 |
if (!a.is('input') || 'checkbox' != a.attr('type')) {
|
296 |
return a;
|
297 |
}
|
298 |
-
|
299 |
$(this).on('change', setAction);
|
300 |
return setAction.call(a);
|
301 |
});
|
302 |
};
|
303 |
-
|
304 |
$.fn.tiwl_byvalueblock = function (so) {
|
305 |
var sd = {
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
return $(this).each(function () {
|
313 |
var a = $(this),
|
314 |
-
|
315 |
-
|
316 |
o_show = o.attr('tiwl-show'),
|
317 |
o_hide = o.attr('tiwl-hide'),
|
318 |
o_ch = s.onClick.call(o),
|
319 |
doAction = function doAction(o_, on) {
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
324 |
};
|
325 |
-
|
326 |
-
if ('string' === typeof o_show) {
|
327 |
-
doAction(o_show, o_ch);
|
328 |
-
}
|
329 |
-
|
330 |
-
if ('string' === typeof o_hide) {
|
331 |
-
doAction(o_hide, !o_ch);
|
332 |
-
}
|
333 |
-
|
334 |
-
return o;
|
335 |
-
};
|
336 |
-
|
337 |
if (!a.is('input') && !a.is('select')) {
|
338 |
return a;
|
339 |
}
|
340 |
-
|
341 |
$(this).on('change', function () {
|
342 |
setAction.call(this, s);
|
343 |
});
|
344 |
return setAction.call(a, s);
|
345 |
});
|
346 |
};
|
347 |
-
|
348 |
var a = new TInvWL($);
|
349 |
$(document).ready(function () {
|
350 |
a.Run();
|
351 |
jQuery('input[name="general-show_notice"]').change(function () {
|
352 |
var o = jQuery(this),
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
if (a && !b.is(':checked')) {
|
357 |
b.click().trigger('change');
|
358 |
}
|
359 |
-
|
360 |
b.closest('.tiwlform-onoff-container').toggleClass('disabled', a);
|
361 |
}).change();
|
362 |
$('.tablenav').each(function () {
|
363 |
var tablenav = $(this);
|
364 |
-
|
365 |
if (!$.trim(tablenav.find('.alignleft').html()).length) {
|
366 |
tablenav.find('.alignleft').remove();
|
367 |
}
|
368 |
-
|
369 |
if (!$.trim(tablenav.find('.alignright').html()).length || tablenav.find('.tablenav-pages').hasClass('one-page')) {
|
370 |
tablenav.find('.alignright').remove();
|
371 |
tablenav.find('.tinv-wishlist-clear').remove();
|
372 |
}
|
373 |
-
|
374 |
if (!$.trim(tablenav.html()).length) {
|
375 |
tablenav.remove();
|
376 |
}
|
@@ -384,7 +324,6 @@ function TInvWL($, h) {
|
|
384 |
e.preventDefault();
|
385 |
$(this).parents('.tinvwl-modal:first').removeClass('tinvwl-modal-open');
|
386 |
});
|
387 |
-
|
388 |
if ('undefined' !== typeof $.fn.popover) {
|
389 |
var popover = $('.tinvwl-help');
|
390 |
popover.popover({
|
@@ -402,11 +341,9 @@ function TInvWL($, h) {
|
|
402 |
popover.popover('hide');
|
403 |
});
|
404 |
}
|
405 |
-
|
406 |
$('body').on('click', '.tinvwl-confirm-reset', function (e) {
|
407 |
e.preventDefault();
|
408 |
var a = confirm(tinvwl_comfirm.text_comfirm_reset);
|
409 |
-
|
410 |
if (a) {
|
411 |
$(this).removeClass('tinvwl-confirm-reset').trigger('click');
|
412 |
}
|
5 |
this.g = '_';
|
6 |
this.ho = h || false;
|
7 |
this.n = 'TInvWL';
|
|
|
8 |
this.aj_act = function (a) {
|
9 |
return [this.pf, a].join(this.g);
|
10 |
};
|
|
|
11 |
this._csel = function (a, b) {
|
12 |
var b = b || '.';
|
13 |
return '{0}{1}{2}'.format(b, this.pf, a);
|
14 |
};
|
|
|
15 |
this._tm = function (a) {
|
16 |
var c = $('script#{0}[type=\'text/template\']'.format(a));
|
|
|
17 |
if (c.length) {
|
18 |
return c.html();
|
19 |
}
|
|
|
20 |
return '';
|
21 |
};
|
|
|
22 |
this.formElm = function () {
|
23 |
$(this._csel('-form-onoff')).tiwl_onoff();
|
24 |
$('input[type=checkbox][tiwl-show], input[type=checkbox][tiwl-hide]').tiwl_onoffblock();
|
25 |
$('[tiwl-value][tiwl-show], [tiwl-value][tiwl-hide]').tiwl_byvalueblock();
|
|
|
26 |
if ('undefined' !== typeof $.fn.wpColorPicker) {
|
27 |
var calcLuminance = function calcLuminance(rgb) {
|
28 |
var c = rgb.substring(1);
|
|
|
29 |
var _rgb = parseInt(c, 16);
|
|
|
30 |
var r = _rgb >> 16 & 0xff;
|
31 |
var g = _rgb >> 8 & 0xff;
|
32 |
var b = _rgb >> 0 & 0xff;
|
33 |
return 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
34 |
};
|
|
|
35 |
var formColor = this._csel('-form-color');
|
|
|
36 |
$(formColor).each(function () {
|
37 |
var picker = $(this);
|
38 |
var pickerWrap = $(this).closest('.tinvwl-color-picker');
|
39 |
var eyedropper = pickerWrap.find('.tinvwl-eyedropper');
|
40 |
picker.css('background-color', picker.val());
|
|
|
41 |
if (175 < calcLuminance(picker.val())) {
|
42 |
picker.css('color', '#000000');
|
43 |
}
|
|
|
44 |
picker.iris({
|
45 |
mode: 'hsv',
|
46 |
target: $(this).parent().parent(),
|
50 |
} else {
|
51 |
$(this).css('color', '');
|
52 |
}
|
|
|
53 |
$(this).css('background-color', ui.color.toCSS());
|
54 |
}
|
55 |
});
|
74 |
});
|
75 |
}
|
76 |
};
|
|
|
77 |
this.wizard_page = function (a) {
|
78 |
$(a).find('select').change(this._wizard_page_ch);
|
79 |
this.wizard_page_ch($(a).find('select'));
|
80 |
};
|
|
|
81 |
this.wizard_page_ch = function (a) {
|
82 |
var a = $(a),
|
83 |
+
b = a.parent(this._csel('-page-select')),
|
84 |
+
c = b.find('input[type=hidden]').val(),
|
85 |
+
d = b.find(this._csel('-error-icon')),
|
86 |
+
e = b.find(this._csel('-error-desc'));
|
|
|
87 |
if ('' === a.val()) {
|
88 |
if (0 == c) {
|
89 |
b.addClass('tinvwl-error');
|
90 |
d.show();
|
91 |
e.show();
|
92 |
}
|
|
|
93 |
return;
|
94 |
}
|
|
|
95 |
b.removeClass('tinvwl-error');
|
96 |
d.hide();
|
97 |
e.hide();
|
98 |
};
|
|
|
99 |
this.pageElm = function () {
|
100 |
$(this._csel('-header', 'div.')).prependTo('#wpbody-content');
|
101 |
$(this._csel('-page-select')).each(this._wizard_page);
|
102 |
$('.bulkactions [type=submit]').each(this._control_bulkactions);
|
103 |
$('.action-search [type=submit]').each(this._control_search);
|
104 |
};
|
|
|
105 |
this.control_bulkactions = function (a) {
|
106 |
$(a).on('click', this._control_bulkactions_ck);
|
107 |
};
|
|
|
108 |
this.control_bulkactions_ck = function (a, b) {
|
109 |
var a = $(a),
|
110 |
+
c = a.parents('.bulkactions').eq(0).find('[name=action]'),
|
111 |
+
d = a.parents('form').eq(0);
|
|
|
112 |
if (c) {
|
113 |
if ('-1' === c.val()) {
|
114 |
b.preventDefault();
|
119 |
}
|
120 |
}
|
121 |
};
|
|
|
122 |
this.control_search = function (a) {
|
123 |
$(a).on('click', this._control_search_ck);
|
124 |
};
|
|
|
125 |
this.control_search_ck = function (a, b) {
|
126 |
var a = $(a),
|
127 |
+
c = a.parents('.action-search').eq(0).find('[name=s]');
|
|
|
128 |
if (c) {
|
129 |
if ('' === c.val()) {
|
130 |
b.preventDefault();
|
131 |
}
|
132 |
}
|
133 |
};
|
|
|
134 |
this.Run = function () {
|
135 |
this.formElm();
|
136 |
this.pageElm();
|
137 |
};
|
|
|
138 |
this.cg = function () {
|
139 |
var n = this.n;
|
|
|
140 |
if (this.ho) {
|
141 |
var t = new Date();
|
142 |
n = n + t.getFullYear() + t.getMonth() + t.getDate();
|
143 |
}
|
|
|
144 |
window[n] = this;
|
145 |
};
|
|
|
146 |
this.cg();
|
|
|
147 |
if (!String.prototype.format) {
|
148 |
String.prototype.format = function () {
|
149 |
var args = arguments;
|
152 |
});
|
153 |
};
|
154 |
}
|
|
|
155 |
(function (o) {
|
156 |
var n = o.n,
|
157 |
+
ho = o.ho,
|
158 |
+
c = '';
|
|
|
159 |
if (ho) {
|
160 |
c = 't=new Date(),n=n+t.getFullYear()+t.getMonth()+t.getDate(),';
|
161 |
}
|
|
|
162 |
for (var i in o) {
|
163 |
if ('function' === typeof o[i] && '_' !== i[0] && !o.hasOwnProperty('_' + i)) {
|
164 |
eval('o._' + i + '=function(a,b,c,d){var n=\'' + n + '\',' + c + 'o=window[n]||null;if (o) {return o.' + i + '(this,a,b,c,d);};};');
|
166 |
}
|
167 |
})(this);
|
168 |
}
|
|
|
169 |
(function ($) {
|
170 |
$.fn.tiwl_onoff = function (so) {
|
171 |
var sd = {
|
172 |
+
value: {
|
173 |
+
on: '',
|
174 |
+
off: ''
|
175 |
+
},
|
176 |
+
class: 'tiwlform-onoff',
|
177 |
+
wrap: 'container',
|
178 |
+
button: 'button'
|
179 |
},
|
180 |
+
s = $.extend(true, {}, sd, so);
|
|
|
|
|
|
|
|
|
181 |
return $(this).each(function () {
|
182 |
var a = $(this),
|
183 |
+
b1 = $('<div>').attr({
|
184 |
+
class: s.class + '-' + s.button
|
185 |
+
}),
|
186 |
+
d1c = s.class + '-' + s.wrap,
|
187 |
+
d1 = $('<div>').attr({
|
188 |
+
id: a.attr('id') + '_' + s.wrap,
|
189 |
+
class: d1c
|
190 |
+
});
|
|
|
191 |
if (!a.is('input')) {
|
192 |
return a;
|
193 |
}
|
|
|
194 |
d1.attr('class', d1.attr('class') + ' ' + a.attr('class'));
|
|
|
195 |
if (a.is(':disabled')) {
|
196 |
d1.toggleClass('disabled', a.is(':disabled'));
|
197 |
a.prop('disabled', false);
|
198 |
}
|
|
|
199 |
d1.toggleClass('checked', a.is(':checked'));
|
200 |
a.hide().removeAttr('class').wrap(d1).before(b1);
|
201 |
d1 = a.parent();
|
203 |
if (d1.hasClass('disabled')) {
|
204 |
return e.preventDefault();
|
205 |
}
|
|
|
206 |
d1.toggleClass('checked', $(this).is(':checked'));
|
207 |
});
|
208 |
d1.on('click', function (e) {
|
209 |
if (d1.hasClass('disabled')) {
|
210 |
return e.preventDefault();
|
211 |
}
|
|
|
212 |
if (a.is(':enabled') && d1.hasClass('checked') === a.is(':checked')) {
|
213 |
a.click();
|
214 |
}
|
216 |
return a;
|
217 |
});
|
218 |
};
|
|
|
219 |
$.fn.tiwl_onoffblock = function (so) {
|
220 |
var sd = {
|
221 |
+
onEachElm: function onEachElm() {},
|
222 |
+
isChecked: function isChecked() {
|
223 |
+
return $(this).is(':checked');
|
224 |
+
}
|
225 |
+
},
|
226 |
+
s = $.extend(true, {}, sd, so);
|
227 |
return $(this).each(function () {
|
228 |
var a = $(this),
|
229 |
+
setAction = function setAction() {
|
230 |
+
var o = $(this),
|
231 |
o_show = o.attr('tiwl-show'),
|
232 |
o_hide = o.attr('tiwl-hide'),
|
233 |
o_ch = s.isChecked.call(o),
|
234 |
doAction = function doAction(o_, on) {
|
235 |
+
o_ = o_.match(/[\w\d-\>\.\#\:\=\[\]]+/igm) || [];
|
236 |
+
$.each(o_, function (k, v) {
|
237 |
+
s.onEachElm.call($(v).toggle(on));
|
238 |
+
});
|
239 |
+
};
|
240 |
+
if ('string' === typeof o_show) {
|
241 |
+
doAction(o_show, o_ch);
|
242 |
+
}
|
243 |
+
if ('string' === typeof o_hide) {
|
244 |
+
doAction(o_hide, !o_ch);
|
245 |
+
}
|
246 |
+
return o;
|
247 |
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
248 |
if (!a.is('input') || 'checkbox' != a.attr('type')) {
|
249 |
return a;
|
250 |
}
|
|
|
251 |
$(this).on('change', setAction);
|
252 |
return setAction.call(a);
|
253 |
});
|
254 |
};
|
|
|
255 |
$.fn.tiwl_byvalueblock = function (so) {
|
256 |
var sd = {
|
257 |
+
onEachElm: function onEachElm() {},
|
258 |
+
onClick: function onClick() {
|
259 |
+
return $(this).val() == $(this).attr('tiwl-value');
|
260 |
+
}
|
261 |
+
},
|
262 |
+
s = $.extend(true, {}, sd, so);
|
263 |
return $(this).each(function () {
|
264 |
var a = $(this),
|
265 |
+
setAction = function setAction(s) {
|
266 |
+
var o = $(this),
|
267 |
o_show = o.attr('tiwl-show'),
|
268 |
o_hide = o.attr('tiwl-hide'),
|
269 |
o_ch = s.onClick.call(o),
|
270 |
doAction = function doAction(o_, on) {
|
271 |
+
o_ = o_.match(/[\w\d-\>\.\#\:\=\[\]]+/igm) || [];
|
272 |
+
$.each(o_, function (k, v) {
|
273 |
+
s.onEachElm.call($(v).toggle(on));
|
274 |
+
});
|
275 |
+
};
|
276 |
+
if ('string' === typeof o_show) {
|
277 |
+
doAction(o_show, o_ch);
|
278 |
+
}
|
279 |
+
if ('string' === typeof o_hide) {
|
280 |
+
doAction(o_hide, !o_ch);
|
281 |
+
}
|
282 |
+
return o;
|
283 |
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
284 |
if (!a.is('input') && !a.is('select')) {
|
285 |
return a;
|
286 |
}
|
|
|
287 |
$(this).on('change', function () {
|
288 |
setAction.call(this, s);
|
289 |
});
|
290 |
return setAction.call(a, s);
|
291 |
});
|
292 |
};
|
|
|
293 |
var a = new TInvWL($);
|
294 |
$(document).ready(function () {
|
295 |
a.Run();
|
296 |
jQuery('input[name="general-show_notice"]').change(function () {
|
297 |
var o = jQuery(this),
|
298 |
+
a = !o.is(':checked'),
|
299 |
+
b = jQuery('input[name="general-redirect_require_login"]');
|
|
|
300 |
if (a && !b.is(':checked')) {
|
301 |
b.click().trigger('change');
|
302 |
}
|
|
|
303 |
b.closest('.tiwlform-onoff-container').toggleClass('disabled', a);
|
304 |
}).change();
|
305 |
$('.tablenav').each(function () {
|
306 |
var tablenav = $(this);
|
|
|
307 |
if (!$.trim(tablenav.find('.alignleft').html()).length) {
|
308 |
tablenav.find('.alignleft').remove();
|
309 |
}
|
|
|
310 |
if (!$.trim(tablenav.find('.alignright').html()).length || tablenav.find('.tablenav-pages').hasClass('one-page')) {
|
311 |
tablenav.find('.alignright').remove();
|
312 |
tablenav.find('.tinv-wishlist-clear').remove();
|
313 |
}
|
|
|
314 |
if (!$.trim(tablenav.html()).length) {
|
315 |
tablenav.remove();
|
316 |
}
|
324 |
e.preventDefault();
|
325 |
$(this).parents('.tinvwl-modal:first').removeClass('tinvwl-modal-open');
|
326 |
});
|
|
|
327 |
if ('undefined' !== typeof $.fn.popover) {
|
328 |
var popover = $('.tinvwl-help');
|
329 |
popover.popover({
|
341 |
popover.popover('hide');
|
342 |
});
|
343 |
}
|
|
|
344 |
$('body').on('click', '.tinvwl-confirm-reset', function (e) {
|
345 |
e.preventDefault();
|
346 |
var a = confirm(tinvwl_comfirm.text_comfirm_reset);
|
|
|
347 |
if (a) {
|
348 |
$(this).removeClass('tinvwl-confirm-reset').trigger('click');
|
349 |
}
|
assets/js/admin.min.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
/**
|
2 |
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
-
* @version 2.0.
|
4 |
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
*/
|
6 |
"use strict";function TInvWL($,h){this.pf="tinvwl",this.g="_",this.ho=h||!1,this.n="TInvWL",this.aj_act=function(t){return[this.pf,t].join(this.g)},this._csel=function(t,n){n=n||".";return"{0}{1}{2}".format(n,this.pf,t)},this._tm=function(t){t=$("script#{0}[type='text/template']".format(t));return t.length?t.html():""},this.formElm=function(){var e,n;$(this._csel("-form-onoff")).tiwl_onoff(),$("input[type=checkbox][tiwl-show], input[type=checkbox][tiwl-hide]").tiwl_onoffblock(),$("[tiwl-value][tiwl-show], [tiwl-value][tiwl-hide]").tiwl_byvalueblock(),void 0!==$.fn.wpColorPicker&&(e=function(t){t=t.substring(1),t=parseInt(t,16);return.2126*(t>>16&255)+.7152*(t>>8&255)+.0722*(t>>0&255)},n=this._csel("-form-color"),$(n).each(function(){var n=$(this),t=$(this).closest(".tinvwl-color-picker"),i=t.find(".tinvwl-eyedropper");n.css("background-color",n.val()),175<e(n.val())&&n.css("color","#000000"),n.iris({mode:"hsv",target:$(this).parent().parent(),change:function(t,n){175<e(n.color.toCSS())?$(this).css("color","#000000"):$(this).css("color",""),$(this).css("background-color",n.color.toCSS())}}),t.on("click",".iris-square-value",function(t){t.preventDefault(),n.iris("toggle")}),i.on("click",function(t){t.preventDefault(),n.iris("show")}),n.on("focusin",function(){n.iris("show")})}),$(document).on("click",function(t){($(t.target).is(n+", .iris-picker, .iris-picker-inner, .iris-slider-offset, .tinvwl-eyedropper, .tinvwl-eyedropper .ftinvwl-eyedropper")?$(n).not($(t.target).closest(".tinvwl-color-picker").find(n)):$(n)).iris("hide")}))},this.wizard_page=function(t){$(t).find("select").change(this._wizard_page_ch),this.wizard_page_ch($(t).find("select"))},this.wizard_page_ch=function(t){var n=(t=$(t)).parent(this._csel("-page-select")),i=n.find("input[type=hidden]").val(),e=n.find(this._csel("-error-icon")),o=n.find(this._csel("-error-desc"));""!==t.val()?(n.removeClass("tinvwl-error"),e.hide(),o.hide()):0==i&&(n.addClass("tinvwl-error"),e.show(),o.show())},this.pageElm=function(){$(this._csel("-header","div.")).prependTo("#wpbody-content"),$(this._csel("-page-select")).each(this._wizard_page),$(".bulkactions [type=submit]").each(this._control_bulkactions),$(".action-search [type=submit]").each(this._control_search)},this.control_bulkactions=function(t){$(t).on("click",this._control_bulkactions_ck)},this.control_bulkactions_ck=function(t,n){var i=(t=$(t)).parents(".bulkactions").eq(0).find("[name=action]"),t=t.parents("form").eq(0);i&&("-1"!==i.val()&&t.find("input[type=checkbox]:checked").length||n.preventDefault())},this.control_search=function(t){$(t).on("click",this._control_search_ck)},this.control_search_ck=function(t,n){t=(t=$(t)).parents(".action-search").eq(0).find("[name=s]");t&&""===t.val()&&n.preventDefault()},this.Run=function(){this.formElm(),this.pageElm()},this.cg=function(){var t,n=this.n;this.ho&&(n=n+(t=new Date).getFullYear()+t.getMonth()+t.getDate()),window[n]=this},this.cg(),String.prototype.format||(String.prototype.format=function(){var i=arguments;return this.replace(/{(\d+)}/g,function(t,n){return void 0!==i[n]?i[n]:t})});var o=this,n=o.n,ho=o.ho,c=ho?"t=new Date(),n=n+t.getFullYear()+t.getMonth()+t.getDate(),":"",i;for(i in o)"function"!=typeof o[i]||"_"===i[0]||o.hasOwnProperty("_"+i)||eval("o._"+i+"=function(a,b,c,d){var n='"+n+"',"+c+"o=window[n]||null;if (o) {return o."+i+"(this,a,b,c,d);};};")}!function(s){s.fn.tiwl_onoff=function(t){var o=s.extend(!0,{},{value:{on:"",off:""},class:"tiwlform-onoff",wrap:"container",button:"button"},t);return s(this).each(function(){var n=s(this),t=s("<div>").attr({class:o.class+"-"+o.button}),i=o.class+"-"+o.wrap,e=s("<div>").attr({id:n.attr("id")+"_"+o.wrap,class:i});return n.is("input")&&(e.attr("class",e.attr("class")+" "+n.attr("class")),n.is(":disabled")&&(e.toggleClass("disabled",n.is(":disabled")),n.prop("disabled",!1)),e.toggleClass("checked",n.is(":checked")),n.hide().removeAttr("class").wrap(e).before(t),e=n.parent(),n.on("change",function(t){if(e.hasClass("disabled"))return t.preventDefault();e.toggleClass("checked",s(this).is(":checked"))}),e.on("click",function(t){if(e.hasClass("disabled"))return t.preventDefault();n.is(":enabled")&&e.hasClass("checked")===n.is(":checked")&&n.click()})),n})},s.fn.tiwl_onoffblock=function(t){var c=s.extend(!0,{},{onEachElm:function(){},isChecked:function(){return s(this).is(":checked")}},t);return s(this).each(function(){function t(){function t(t,i){t=t.match(/[\w\d-\>\.\#\:\=\[\]]+/gim)||[],s.each(t,function(t,n){c.onEachElm.call(s(n).toggle(i))})}var n=s(this),i=n.attr("tiwl-show"),e=n.attr("tiwl-hide"),o=c.isChecked.call(n);return"string"==typeof i&&t(i,o),"string"==typeof e&&t(e,!o),n}var n=s(this);return n.is("input")&&"checkbox"==n.attr("type")?(s(this).on("change",t),t.call(n)):n})},s.fn.tiwl_byvalueblock=function(t){var i=s.extend(!0,{},{onEachElm:function(){},onClick:function(){return s(this).val()==s(this).attr("tiwl-value")}},t);return s(this).each(function(){function t(e){function t(t,i){t=t.match(/[\w\d-\>\.\#\:\=\[\]]+/gim)||[],s.each(t,function(t,n){e.onEachElm.call(s(n).toggle(i))})}var n=s(this),i=n.attr("tiwl-show"),o=n.attr("tiwl-hide"),c=e.onClick.call(n);return"string"==typeof i&&t(i,c),"string"==typeof o&&t(o,!c),n}var n=s(this);return n.is("input")||n.is("select")?(s(this).on("change",function(){t.call(this,i)}),t.call(n,i)):n})};var n=new TInvWL(s);s(document).ready(function(){var t;n.Run(),jQuery('input[name="general-show_notice"]').change(function(){var t=!jQuery(this).is(":checked"),n=jQuery('input[name="general-redirect_require_login"]');t&&!n.is(":checked")&&n.click().trigger("change"),n.closest(".tiwlform-onoff-container").toggleClass("disabled",t)}).change(),s(".tablenav").each(function(){var t=s(this);s.trim(t.find(".alignleft").html()).length||t.find(".alignleft").remove(),s.trim(t.find(".alignright").html()).length&&!t.find(".tablenav-pages").hasClass("one-page")||(t.find(".alignright").remove(),t.find(".tinv-wishlist-clear").remove()),s.trim(t.html()).length||t.remove()}),s(".tablenav .bulkactions select").addClass("tinvwl-select grey").wrap('<span class="tinvwl-select-wrap">').parent().append('<span class="tinvwl-caret"><span></span></span>'),s(".tablenav .bulkactions .button.action, .tablenav #search-submit").removeClass("button").addClass("tinvwl-btn grey"),s(".tinvwl-modal-btn").on("click",function(){s(this).next(".tinvwl-modal").addClass("tinvwl-modal-open")}),s(".tinvwl-overlay, .tinvwl-close-modal, .tinvwl_button_close").on("click",function(t){t.preventDefault(),s(this).parents(".tinvwl-modal:first").removeClass("tinvwl-modal-open")}),void 0!==s.fn.popover&&((t=s(".tinvwl-help")).popover({content:function(){return s(this).closest(".tinvwl-info-wrap").find(".tinvwl-info-desc").html()}}),t.on("click",function(){s(this).popover("toggle")}),t.on("focusout",function(){s(this).popover("hide")}),s(window).on("resize",function(){t.popover("hide")})),s("body").on("click",".tinvwl-confirm-reset",function(t){t.preventDefault(),confirm(tinvwl_comfirm.text_comfirm_reset)&&s(this).removeClass("tinvwl-confirm-reset").trigger("click")})}),s(document).on("click",".tinvwl-chat-notice .notice-dismiss",function(t){s.post(tinvwl_comfirm.ajax_url,{action:"tinvwl_admin_chat_notice"})})}(jQuery);
|
1 |
/**
|
2 |
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
+
* @version 2.0.7
|
4 |
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
*/
|
6 |
"use strict";function TInvWL($,h){this.pf="tinvwl",this.g="_",this.ho=h||!1,this.n="TInvWL",this.aj_act=function(t){return[this.pf,t].join(this.g)},this._csel=function(t,n){n=n||".";return"{0}{1}{2}".format(n,this.pf,t)},this._tm=function(t){t=$("script#{0}[type='text/template']".format(t));return t.length?t.html():""},this.formElm=function(){var e,n;$(this._csel("-form-onoff")).tiwl_onoff(),$("input[type=checkbox][tiwl-show], input[type=checkbox][tiwl-hide]").tiwl_onoffblock(),$("[tiwl-value][tiwl-show], [tiwl-value][tiwl-hide]").tiwl_byvalueblock(),void 0!==$.fn.wpColorPicker&&(e=function(t){t=t.substring(1),t=parseInt(t,16);return.2126*(t>>16&255)+.7152*(t>>8&255)+.0722*(t>>0&255)},n=this._csel("-form-color"),$(n).each(function(){var n=$(this),t=$(this).closest(".tinvwl-color-picker"),i=t.find(".tinvwl-eyedropper");n.css("background-color",n.val()),175<e(n.val())&&n.css("color","#000000"),n.iris({mode:"hsv",target:$(this).parent().parent(),change:function(t,n){175<e(n.color.toCSS())?$(this).css("color","#000000"):$(this).css("color",""),$(this).css("background-color",n.color.toCSS())}}),t.on("click",".iris-square-value",function(t){t.preventDefault(),n.iris("toggle")}),i.on("click",function(t){t.preventDefault(),n.iris("show")}),n.on("focusin",function(){n.iris("show")})}),$(document).on("click",function(t){($(t.target).is(n+", .iris-picker, .iris-picker-inner, .iris-slider-offset, .tinvwl-eyedropper, .tinvwl-eyedropper .ftinvwl-eyedropper")?$(n).not($(t.target).closest(".tinvwl-color-picker").find(n)):$(n)).iris("hide")}))},this.wizard_page=function(t){$(t).find("select").change(this._wizard_page_ch),this.wizard_page_ch($(t).find("select"))},this.wizard_page_ch=function(t){var n=(t=$(t)).parent(this._csel("-page-select")),i=n.find("input[type=hidden]").val(),e=n.find(this._csel("-error-icon")),o=n.find(this._csel("-error-desc"));""!==t.val()?(n.removeClass("tinvwl-error"),e.hide(),o.hide()):0==i&&(n.addClass("tinvwl-error"),e.show(),o.show())},this.pageElm=function(){$(this._csel("-header","div.")).prependTo("#wpbody-content"),$(this._csel("-page-select")).each(this._wizard_page),$(".bulkactions [type=submit]").each(this._control_bulkactions),$(".action-search [type=submit]").each(this._control_search)},this.control_bulkactions=function(t){$(t).on("click",this._control_bulkactions_ck)},this.control_bulkactions_ck=function(t,n){var i=(t=$(t)).parents(".bulkactions").eq(0).find("[name=action]"),t=t.parents("form").eq(0);i&&("-1"!==i.val()&&t.find("input[type=checkbox]:checked").length||n.preventDefault())},this.control_search=function(t){$(t).on("click",this._control_search_ck)},this.control_search_ck=function(t,n){t=(t=$(t)).parents(".action-search").eq(0).find("[name=s]");t&&""===t.val()&&n.preventDefault()},this.Run=function(){this.formElm(),this.pageElm()},this.cg=function(){var t,n=this.n;this.ho&&(n=n+(t=new Date).getFullYear()+t.getMonth()+t.getDate()),window[n]=this},this.cg(),String.prototype.format||(String.prototype.format=function(){var i=arguments;return this.replace(/{(\d+)}/g,function(t,n){return void 0!==i[n]?i[n]:t})});var o=this,n=o.n,ho=o.ho,c=ho?"t=new Date(),n=n+t.getFullYear()+t.getMonth()+t.getDate(),":"",i;for(i in o)"function"!=typeof o[i]||"_"===i[0]||o.hasOwnProperty("_"+i)||eval("o._"+i+"=function(a,b,c,d){var n='"+n+"',"+c+"o=window[n]||null;if (o) {return o."+i+"(this,a,b,c,d);};};")}!function(s){s.fn.tiwl_onoff=function(t){var o=s.extend(!0,{},{value:{on:"",off:""},class:"tiwlform-onoff",wrap:"container",button:"button"},t);return s(this).each(function(){var n=s(this),t=s("<div>").attr({class:o.class+"-"+o.button}),i=o.class+"-"+o.wrap,e=s("<div>").attr({id:n.attr("id")+"_"+o.wrap,class:i});return n.is("input")&&(e.attr("class",e.attr("class")+" "+n.attr("class")),n.is(":disabled")&&(e.toggleClass("disabled",n.is(":disabled")),n.prop("disabled",!1)),e.toggleClass("checked",n.is(":checked")),n.hide().removeAttr("class").wrap(e).before(t),e=n.parent(),n.on("change",function(t){if(e.hasClass("disabled"))return t.preventDefault();e.toggleClass("checked",s(this).is(":checked"))}),e.on("click",function(t){if(e.hasClass("disabled"))return t.preventDefault();n.is(":enabled")&&e.hasClass("checked")===n.is(":checked")&&n.click()})),n})},s.fn.tiwl_onoffblock=function(t){var c=s.extend(!0,{},{onEachElm:function(){},isChecked:function(){return s(this).is(":checked")}},t);return s(this).each(function(){function t(){function t(t,i){t=t.match(/[\w\d-\>\.\#\:\=\[\]]+/gim)||[],s.each(t,function(t,n){c.onEachElm.call(s(n).toggle(i))})}var n=s(this),i=n.attr("tiwl-show"),e=n.attr("tiwl-hide"),o=c.isChecked.call(n);return"string"==typeof i&&t(i,o),"string"==typeof e&&t(e,!o),n}var n=s(this);return n.is("input")&&"checkbox"==n.attr("type")?(s(this).on("change",t),t.call(n)):n})},s.fn.tiwl_byvalueblock=function(t){var i=s.extend(!0,{},{onEachElm:function(){},onClick:function(){return s(this).val()==s(this).attr("tiwl-value")}},t);return s(this).each(function(){function t(e){function t(t,i){t=t.match(/[\w\d-\>\.\#\:\=\[\]]+/gim)||[],s.each(t,function(t,n){e.onEachElm.call(s(n).toggle(i))})}var n=s(this),i=n.attr("tiwl-show"),o=n.attr("tiwl-hide"),c=e.onClick.call(n);return"string"==typeof i&&t(i,c),"string"==typeof o&&t(o,!c),n}var n=s(this);return n.is("input")||n.is("select")?(s(this).on("change",function(){t.call(this,i)}),t.call(n,i)):n})};var n=new TInvWL(s);s(document).ready(function(){var t;n.Run(),jQuery('input[name="general-show_notice"]').change(function(){var t=!jQuery(this).is(":checked"),n=jQuery('input[name="general-redirect_require_login"]');t&&!n.is(":checked")&&n.click().trigger("change"),n.closest(".tiwlform-onoff-container").toggleClass("disabled",t)}).change(),s(".tablenav").each(function(){var t=s(this);s.trim(t.find(".alignleft").html()).length||t.find(".alignleft").remove(),s.trim(t.find(".alignright").html()).length&&!t.find(".tablenav-pages").hasClass("one-page")||(t.find(".alignright").remove(),t.find(".tinv-wishlist-clear").remove()),s.trim(t.html()).length||t.remove()}),s(".tablenav .bulkactions select").addClass("tinvwl-select grey").wrap('<span class="tinvwl-select-wrap">').parent().append('<span class="tinvwl-caret"><span></span></span>'),s(".tablenav .bulkactions .button.action, .tablenav #search-submit").removeClass("button").addClass("tinvwl-btn grey"),s(".tinvwl-modal-btn").on("click",function(){s(this).next(".tinvwl-modal").addClass("tinvwl-modal-open")}),s(".tinvwl-overlay, .tinvwl-close-modal, .tinvwl_button_close").on("click",function(t){t.preventDefault(),s(this).parents(".tinvwl-modal:first").removeClass("tinvwl-modal-open")}),void 0!==s.fn.popover&&((t=s(".tinvwl-help")).popover({content:function(){return s(this).closest(".tinvwl-info-wrap").find(".tinvwl-info-desc").html()}}),t.on("click",function(){s(this).popover("toggle")}),t.on("focusout",function(){s(this).popover("hide")}),s(window).on("resize",function(){t.popover("hide")})),s("body").on("click",".tinvwl-confirm-reset",function(t){t.preventDefault(),confirm(tinvwl_comfirm.text_comfirm_reset)&&s(this).removeClass("tinvwl-confirm-reset").trigger("click")})}),s(document).on("click",".tinvwl-chat-notice .notice-dismiss",function(t){s.post(tinvwl_comfirm.ajax_url,{action:"tinvwl_admin_chat_notice"})})}(jQuery);
|
assets/js/public.js
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
"use strict";
|
2 |
|
3 |
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
4 |
-
|
5 |
// Add to wishlist
|
6 |
(function ($) {
|
7 |
//Add to wishlist main function.
|
@@ -23,7 +22,6 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
23 |
if (!$('body > .tinv-wishlist').length) {
|
24 |
$('body').append($('<div>').addClass('tinv-wishlist'));
|
25 |
}
|
26 |
-
|
27 |
$(this).appendTo('body > .tinv-wishlist');
|
28 |
},
|
29 |
onCreateWishList: function onCreateWishList(wishlist) {
|
@@ -43,11 +41,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
43 |
if ($(this).is('.disabled-add-wishlist')) {
|
44 |
return false;
|
45 |
}
|
46 |
-
|
47 |
if ($(this).is('.ftinvwl-animated')) {
|
48 |
$(this).addClass('ftinvwl-pulse');
|
49 |
}
|
50 |
-
|
51 |
if (this.tinvwl_dialog) {
|
52 |
this.tinvwl_dialog.show_list.call(this);
|
53 |
} else {
|
@@ -59,12 +55,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
59 |
},
|
60 |
filterProductAlreadyIn: function filterProductAlreadyIn(WList) {
|
61 |
var WList = WList || [],
|
62 |
-
|
63 |
$('form.cart[method=post], .woocommerce-variation-add-to-cart, form.vtajaxform[method=post]').find('input, select').each(function () {
|
64 |
var name_elm = $(this).attr('name'),
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
if ('checkbox' === type_elm || 'radio' === type_elm) {
|
69 |
if ($(this).is(':checked')) {
|
70 |
data['form' + name_elm] = value_elm;
|
@@ -79,7 +74,6 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
79 |
var number = parseInt(data);
|
80 |
return 0 <= wishlist.in.indexOf(number);
|
81 |
}
|
82 |
-
|
83 |
return wishlist.in;
|
84 |
});
|
85 |
},
|
@@ -89,11 +83,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
89 |
WList = s.filterProductAlreadyIn.call(this, WList) || WList;
|
90 |
$(this).parent().parent().find('.already-in').remove();
|
91 |
var text = '';
|
92 |
-
|
93 |
switch (WList.length) {
|
94 |
case 0:
|
95 |
break;
|
96 |
-
|
97 |
default:
|
98 |
var text = $('<ul>');
|
99 |
$.each(WList, function (k, wishlist) {
|
@@ -103,7 +95,6 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
103 |
});
|
104 |
break;
|
105 |
}
|
106 |
-
|
107 |
if (text.length) {
|
108 |
$(this).closest('.tinv-modal-inner').find('img').after($('<div>').addClass('already-in').html(s.text_already_in + ' ').append(text));
|
109 |
}
|
@@ -113,7 +104,6 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
113 |
if (s.redirectTimer) {
|
114 |
clearTimeout(s.redirectTimer);
|
115 |
}
|
116 |
-
|
117 |
s.redirectTimer = window.setTimeout(function () {
|
118 |
window.location.href = url;
|
119 |
}, 4000);
|
@@ -126,34 +116,26 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
126 |
if (!html) {
|
127 |
return false;
|
128 |
}
|
129 |
-
|
130 |
var $msg = $(html).eq(0);
|
131 |
-
|
132 |
if (!$('body > .tinv-wishlist').length) {
|
133 |
$('body').append($('<div>').addClass('tinv-wishlist'));
|
134 |
}
|
135 |
-
|
136 |
$('body > .tinv-wishlist').append($msg);
|
137 |
FocusTrap('body > .tinv-wishlist');
|
138 |
-
|
139 |
if (!s.redirectTimer) {
|
140 |
s.removeTimer = window.setTimeout(function () {
|
141 |
$msg.remove();
|
142 |
-
|
143 |
if (s.redirectTimer) {
|
144 |
clearTimeout(s.redirectTimer);
|
145 |
}
|
146 |
}, tinvwl_add_to_wishlist.popup_timer);
|
147 |
}
|
148 |
-
|
149 |
$msg.on('click', '.tinv-close-modal, .tinvwl_button_close, .tinv-overlay', function (e) {
|
150 |
e.preventDefault();
|
151 |
$msg.remove();
|
152 |
-
|
153 |
if (s.redirectTimer) {
|
154 |
clearTimeout(s.redirectTimer);
|
155 |
}
|
156 |
-
|
157 |
if (s.removeTimer) {
|
158 |
clearTimeout(s.removeTimer);
|
159 |
}
|
@@ -169,115 +151,95 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
169 |
}
|
170 |
}
|
171 |
};
|
172 |
-
|
173 |
sd.onActionProduct = function (id, name) {
|
174 |
var data = {
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
if (tinvwl_add_to_wishlist.wpml) {
|
189 |
data.lang = tinvwl_add_to_wishlist.wpml;
|
190 |
}
|
191 |
-
|
192 |
if (tinvwl_add_to_wishlist.wpml_default) {
|
193 |
data.lang_default = tinvwl_add_to_wishlist.wpml_default;
|
194 |
}
|
195 |
-
|
196 |
if ('1' == tinvwl_add_to_wishlist.stats) {
|
197 |
data.stats = tinvwl_add_to_wishlist.stats;
|
198 |
}
|
199 |
-
|
200 |
$('form.cart[method=post][data-product_id="' + $(this).attr('data-tinv-wl-product') + '"], form.vtajaxform[method=post][data-product_id="' + $(this).attr('data-tinv-wl-product') + '"]').each(function () {
|
201 |
formEl.push($(this));
|
202 |
});
|
203 |
-
|
204 |
if (!formEl.length) {
|
205 |
$(a).closest('form.cart[method=post], form.vtajaxform[method=post]').each(function () {
|
206 |
formEl.push($(this));
|
207 |
});
|
208 |
-
|
209 |
if (!formEl.length) {
|
210 |
formEl.push($('form.cart[method=post]'));
|
211 |
}
|
212 |
}
|
213 |
-
|
214 |
$('.tinv-wraper[data-tinvwl_product_id="' + $(this).attr('data-tinv-wl-product') + '"]').each(function () {
|
215 |
formEl.push($(this));
|
216 |
});
|
217 |
$.each(formEl, function (index, element) {
|
218 |
$(element).find('input:not(:disabled), select:not(:disabled), textarea:not(:disabled)').each(function () {
|
219 |
var name_elm = $(this).attr('name'),
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
j = j;
|
|
|
|
|
|
|
235 |
}
|
236 |
-
|
237 |
-
j = parseInt(j) + 1;
|
238 |
-
o1[j] = ti_merge_value(o1[i], o2[i]);
|
239 |
-
} else {
|
240 |
-
o1[i] = ti_merge_value(o1[i], o2[i]);
|
241 |
}
|
|
|
|
|
|
|
242 |
}
|
243 |
-
|
244 |
-
return o1;
|
245 |
-
} else {
|
246 |
-
return o2;
|
247 |
-
}
|
248 |
-
};
|
249 |
-
|
250 |
if ('button' === type_elm || 'undefined' == typeof name_elm) {
|
251 |
return;
|
252 |
}
|
253 |
-
|
254 |
while (/^(.+)\[([^\[\]]*?)\]$/.test(name_elm) && 0 < count) {
|
255 |
var n_name = name_elm.match(/^(.+)\[([^\[\]]*?)\]$/);
|
256 |
-
|
257 |
if (3 === n_name.length) {
|
258 |
var _value_elm = {};
|
259 |
_value_elm[n_name[2]] = value_elm;
|
260 |
value_elm = _value_elm;
|
261 |
}
|
262 |
-
|
263 |
name_elm = n_name[1];
|
264 |
count--;
|
265 |
}
|
266 |
-
|
267 |
if ('file' === type_elm) {
|
268 |
var file_data = $(this)[0].files;
|
269 |
-
|
270 |
if (file_data) {
|
271 |
formData.append(name_elm, file_data[0]);
|
272 |
}
|
273 |
}
|
274 |
-
|
275 |
if ('checkbox' === type_elm || 'radio' === type_elm) {
|
276 |
if ($(this).is(':checked')) {
|
277 |
if (!value_elm.length && 'object' !== _typeof(value_elm)) {
|
278 |
value_elm = true;
|
279 |
}
|
280 |
-
|
281 |
data.form[name_elm] = ti_merge_value(data.form[name_elm], value_elm);
|
282 |
}
|
283 |
} else {
|
@@ -292,7 +254,6 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
292 |
if ('object' === _typeof(v)) {
|
293 |
v = JSON.stringify(v);
|
294 |
}
|
295 |
-
|
296 |
formData.append(key + '[' + k + ']', v);
|
297 |
});
|
298 |
} else {
|
@@ -308,7 +269,6 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
308 |
}).done(function (body) {
|
309 |
$('body').trigger('tinvwl_wishlist_ajax_response', [this, body]);
|
310 |
s.onDialogHide.call(a.tinvwl_dialog, a);
|
311 |
-
|
312 |
if ('object' === _typeof(body)) {
|
313 |
for (var k in body) {
|
314 |
if ('function' === typeof s.onAction[k]) {
|
@@ -322,34 +282,27 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
322 |
}
|
323 |
});
|
324 |
};
|
325 |
-
|
326 |
var s = $.extend(true, {}, sd, so);
|
327 |
return $(this).each(function () {
|
328 |
if (!$(this).attr('data-tinv-wl-list')) {
|
329 |
return false;
|
330 |
}
|
331 |
-
|
332 |
if (s.dialogbox) {
|
333 |
if (s.dialogbox.length) {
|
334 |
this.tinvwl_dialog = s.dialogbox;
|
335 |
}
|
336 |
}
|
337 |
-
|
338 |
if (!this.tinvwl_dialog) {
|
339 |
this.tinvwl_dialog = s.onGetDialogBox.call(this);
|
340 |
}
|
341 |
-
|
342 |
if (!this.tinvwl_dialog) {
|
343 |
var _tinvwl_dialog = $(this).nextAll(s.class.dialogbox).eq(0);
|
344 |
-
|
345 |
if (_tinvwl_dialog.length) {
|
346 |
this.tinvwl_dialog = _tinvwl_dialog;
|
347 |
}
|
348 |
}
|
349 |
-
|
350 |
if (this.tinvwl_dialog) {
|
351 |
s.onPrepareDialogBox.call(this.tinvwl_dialog);
|
352 |
-
|
353 |
if ('function' !== typeof this.tinvwl_dialog.update_list) {
|
354 |
this.tinvwl_dialog.update_list = function (WL) {
|
355 |
var $select = $(this).find(s.class.select).eq(0);
|
@@ -358,7 +311,6 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
358 |
$.each(WL, function (k, v) {
|
359 |
s.onCreateWishList.call($select, v);
|
360 |
});
|
361 |
-
|
362 |
if (s.text_create) {
|
363 |
s.onCreateWishList.call($select, {
|
364 |
ID: '',
|
@@ -366,17 +318,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
366 |
in: false
|
367 |
});
|
368 |
}
|
369 |
-
|
370 |
s.onMultiProductAlreadyIn.call($select, WL);
|
371 |
s.onSelectWishList.call($select, WL);
|
372 |
$(this).find(s.class.newtitle).toggle('' === $select.val());
|
373 |
};
|
374 |
}
|
375 |
-
|
376 |
if ('function' !== typeof this.tinvwl_dialog.show_list) {
|
377 |
this.tinvwl_dialog.show_list = function () {
|
378 |
var WList = JSON.parse($(this).attr('data-tinv-wl-list')) || [];
|
379 |
-
|
380 |
if (WList.length) {
|
381 |
WList = s.onPrepareList.call(WList) || WList;
|
382 |
this.tinvwl_dialog.update_list(WList);
|
@@ -386,13 +335,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
386 |
}
|
387 |
};
|
388 |
}
|
389 |
-
|
390 |
var a = this;
|
391 |
$(this.tinvwl_dialog).find(s.class.dialogbutton).off('click').on('click', function () {
|
392 |
var b = $(a.tinvwl_dialog).find(s.class.select),
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
if (b.val() || c.val()) {
|
397 |
s.onActionProduct.call(a, b.val(), c.val());
|
398 |
} else {
|
@@ -404,90 +351,91 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
404 |
}
|
405 |
});
|
406 |
}
|
407 |
-
|
408 |
$(this).off('click').on('click', s.onClick);
|
409 |
s.onInited.call(this, s);
|
410 |
});
|
411 |
};
|
412 |
-
|
413 |
$(document).ready(function () {
|
414 |
// Add to wishlist button click
|
415 |
$('body').on('click keydown', '.tinvwl_add_to_wishlist_button', function (e) {
|
416 |
if ('keydown' === e.type) {
|
417 |
-
var keyD = e.key !== undefined ? e.key : e.keyCode;
|
|
|
|
|
418 |
// I tested within IE11, Firefox, Chrome, Edge (latest) & all had good support for e.key
|
419 |
|
420 |
if (!('Enter' === keyD || 13 === keyD || 0 <= ['Spacebar', ' '].indexOf(keyD) || 32 === keyD)) {
|
421 |
return;
|
422 |
}
|
423 |
-
|
424 |
e.preventDefault();
|
425 |
}
|
426 |
-
|
427 |
$('body').trigger('tinvwl_add_to_wishlist_button_click', [this]);
|
428 |
-
|
429 |
if ($(this).is('.disabled-add-wishlist')) {
|
430 |
e.preventDefault();
|
431 |
window.alert(tinvwl_add_to_wishlist.i18n_make_a_selection_text);
|
432 |
return;
|
433 |
}
|
434 |
-
|
435 |
if ($(this).is('.inited-add-wishlist')) {
|
436 |
return;
|
437 |
}
|
438 |
-
|
439 |
$(this).tinvwl_to_wishlist({
|
440 |
onInited: function onInited(s) {
|
441 |
$(this).addClass('inited-add-wishlist');
|
442 |
s.onClick.call(this);
|
443 |
}
|
444 |
});
|
445 |
-
});
|
446 |
|
|
|
447 |
$('body').on('click keydown', 'button[name="tinvwl-remove"]', function (e) {
|
448 |
if ('keydown' === e.type) {
|
449 |
-
var keyD = e.key !== undefined ? e.key : e.keyCode;
|
|
|
|
|
450 |
// I tested within IE11, Firefox, Chrome, Edge (latest) & all had good support for e.key
|
451 |
|
452 |
if (!('Enter' === keyD || 13 === keyD || 0 <= ['Spacebar', ' '].indexOf(keyD) || 32 === keyD)) {
|
453 |
return;
|
454 |
}
|
455 |
}
|
456 |
-
|
457 |
e.preventDefault();
|
458 |
var el = $(this);
|
459 |
-
|
460 |
if (el.is('.inited-wishlist-action')) {
|
461 |
return;
|
462 |
}
|
463 |
-
|
464 |
el.addClass('inited-wishlist-action');
|
465 |
-
var
|
466 |
'tinvwl-product_id': el.val(),
|
467 |
'tinvwl-action': 'remove',
|
468 |
'tinvwl-security': tinvwl_add_to_wishlist.nonce,
|
469 |
'tinvwl-paged': el.closest('form').data('tinvwl_paged'),
|
470 |
'tinvwl-sharekey': el.closest('form').data('tinvwl_sharekey')
|
471 |
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
472 |
$.ajax({
|
473 |
url: tinvwl_add_to_wishlist.wc_ajax_url,
|
474 |
method: 'POST',
|
475 |
cache: false,
|
476 |
-
data:
|
477 |
beforeSend: function beforeSend(xhr) {
|
478 |
xhr.setRequestHeader('X-WP-Nonce', tinvwl_add_to_wishlist.nonce);
|
479 |
}
|
480 |
}).done(function (response) {
|
481 |
$('body').trigger('tinvwl_wishlist_ajax_response', [this, response]);
|
482 |
el.removeClass('inited-wishlist-action');
|
483 |
-
|
484 |
if (response.msg) {
|
485 |
var $msg = $(response.msg).eq(0);
|
486 |
-
|
487 |
if (!$('body > .tinv-wishlist').length) {
|
488 |
$('body').append($('<div>').addClass('tinv-wishlist'));
|
489 |
}
|
490 |
-
|
491 |
$('body > .tinv-wishlist').append($msg);
|
492 |
FocusTrap('body > .tinv-wishlist');
|
493 |
$msg.on('click', '.tinv-close-modal, .tinvwl_button_close, .tinv-overlay', function (e) {
|
@@ -495,18 +443,15 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
495 |
$msg.remove();
|
496 |
});
|
497 |
var closeTimer;
|
498 |
-
|
499 |
if (!closeTimer) {
|
500 |
closeTimer = window.setTimeout(function () {
|
501 |
$msg.remove();
|
502 |
-
|
503 |
if (closeTimer) {
|
504 |
clearTimeout(closeTimer);
|
505 |
}
|
506 |
}, tinvwl_add_to_wishlist.popup_timer);
|
507 |
}
|
508 |
}
|
509 |
-
|
510 |
if (response.status) {
|
511 |
$('div.tinv-wishlist.woocommerce.tinv-wishlist-clear').replaceWith(response.content);
|
512 |
$('.tinvwl-break-input').tinvwl_break_submit({
|
@@ -520,61 +465,65 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
520 |
});
|
521 |
jQuery.fn.tinvwl_get_wishlist_data();
|
522 |
}
|
523 |
-
|
524 |
if (response.wishlists_data) {
|
525 |
set_hash(JSON.stringify(response.wishlists_data));
|
526 |
}
|
527 |
});
|
528 |
-
});
|
529 |
|
|
|
530 |
$('body').on('click keydown', 'button[name="tinvwl-add-to-cart"]', function (e) {
|
531 |
if ('keydown' === e.type) {
|
532 |
-
var keyD = e.key !== undefined ? e.key : e.keyCode;
|
|
|
|
|
533 |
// I tested within IE11, Firefox, Chrome, Edge (latest) & all had good support for e.key
|
534 |
|
535 |
if (!('Enter' === keyD || 13 === keyD || 0 <= ['Spacebar', ' '].indexOf(keyD) || 32 === keyD)) {
|
536 |
return;
|
537 |
}
|
538 |
}
|
539 |
-
|
540 |
e.preventDefault();
|
541 |
var el = $(this);
|
542 |
-
|
543 |
if (el.is('.inited-wishlist-action')) {
|
544 |
return;
|
545 |
}
|
546 |
-
|
547 |
el.addClass('inited-wishlist-action');
|
548 |
-
var
|
549 |
'tinvwl-product_id': el.val(),
|
550 |
'tinvwl-action': 'add_to_cart_single',
|
551 |
'tinvwl-security': tinvwl_add_to_wishlist.nonce,
|
552 |
'tinvwl-paged': el.closest('form').data('tinvwl_paged'),
|
553 |
'tinvwl-sharekey': el.closest('form').data('tinvwl_sharekey')
|
554 |
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
555 |
$.ajax({
|
556 |
url: tinvwl_add_to_wishlist.wc_ajax_url,
|
557 |
method: 'POST',
|
558 |
cache: false,
|
559 |
-
data:
|
560 |
beforeSend: function beforeSend(xhr) {
|
561 |
xhr.setRequestHeader('X-WP-Nonce', tinvwl_add_to_wishlist.nonce);
|
562 |
}
|
563 |
}).done(function (response) {
|
564 |
$('body').trigger('tinvwl_wishlist_ajax_response', [this, response]);
|
565 |
el.removeClass('inited-wishlist-action');
|
566 |
-
|
567 |
if (response.redirect) {
|
568 |
window.location.href = response.redirect;
|
569 |
}
|
570 |
-
|
571 |
if (response.msg) {
|
572 |
var $msg = $(response.msg).eq(0);
|
573 |
-
|
574 |
if (!$('body > .tinv-wishlist').length) {
|
575 |
$('body').append($('<div>').addClass('tinv-wishlist'));
|
576 |
}
|
577 |
-
|
578 |
$('body > .tinv-wishlist').append($msg);
|
579 |
FocusTrap('body > .tinv-wishlist');
|
580 |
$msg.on('click', '.tinv-close-modal, .tinvwl_button_close, .tinv-overlay', function (e) {
|
@@ -582,79 +531,79 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
582 |
$msg.remove();
|
583 |
});
|
584 |
var closeTimer;
|
585 |
-
|
586 |
if (!closeTimer) {
|
587 |
closeTimer = window.setTimeout(function () {
|
588 |
$msg.remove();
|
589 |
-
|
590 |
if (closeTimer) {
|
591 |
clearTimeout(closeTimer);
|
592 |
}
|
593 |
}, tinvwl_add_to_wishlist.popup_timer);
|
594 |
}
|
595 |
}
|
596 |
-
|
597 |
if (response.redirect) {
|
598 |
return;
|
599 |
}
|
600 |
-
|
601 |
$(document.body).trigger('wc_fragment_refresh');
|
602 |
$('div.tinv-wishlist.woocommerce.tinv-wishlist-clear').replaceWith(response.content);
|
603 |
jQuery.fn.tinvwl_get_wishlist_data();
|
604 |
-
|
605 |
if (response.wishlists_data) {
|
606 |
set_hash(JSON.stringify(response.wishlists_data));
|
607 |
}
|
608 |
});
|
609 |
-
});
|
610 |
|
|
|
611 |
$('body').on('click keydown', 'button[name="tinvwl-action-product_all"]', function (e) {
|
612 |
if ('keydown' === e.type) {
|
613 |
-
var keyD = e.key !== undefined ? e.key : e.keyCode;
|
|
|
|
|
614 |
// I tested within IE11, Firefox, Chrome, Edge (latest) & all had good support for e.key
|
615 |
|
616 |
if (!('Enter' === keyD || 13 === keyD || 0 <= ['Spacebar', ' '].indexOf(keyD) || 32 === keyD)) {
|
617 |
return;
|
618 |
}
|
619 |
}
|
620 |
-
|
621 |
e.preventDefault();
|
622 |
var el = $(this);
|
623 |
-
|
624 |
if (el.is('.inited-wishlist-action')) {
|
625 |
return;
|
626 |
}
|
627 |
-
|
628 |
el.addClass('inited-wishlist-action');
|
629 |
-
var
|
630 |
'tinvwl-action': 'add_to_cart_all',
|
631 |
'tinvwl-security': tinvwl_add_to_wishlist.nonce,
|
632 |
'tinvwl-paged': el.closest('form').data('tinvwl_paged'),
|
633 |
'tinvwl-sharekey': el.closest('form').data('tinvwl_sharekey')
|
634 |
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
635 |
$.ajax({
|
636 |
url: tinvwl_add_to_wishlist.wc_ajax_url,
|
637 |
method: 'POST',
|
638 |
cache: false,
|
639 |
-
data:
|
640 |
beforeSend: function beforeSend(xhr) {
|
641 |
xhr.setRequestHeader('X-WP-Nonce', tinvwl_add_to_wishlist.nonce);
|
642 |
}
|
643 |
}).done(function (response) {
|
644 |
$('body').trigger('tinvwl_wishlist_ajax_response', [this, response]);
|
645 |
el.removeClass('inited-wishlist-action');
|
646 |
-
|
647 |
if (response.redirect) {
|
648 |
window.location.href = response.redirect;
|
649 |
}
|
650 |
-
|
651 |
if (response.msg) {
|
652 |
var $msg = $(response.msg).eq(0);
|
653 |
-
|
654 |
if (!$('body > .tinv-wishlist').length) {
|
655 |
$('body').append($('<div>').addClass('tinv-wishlist'));
|
656 |
}
|
657 |
-
|
658 |
$('body > .tinv-wishlist').append($msg);
|
659 |
FocusTrap('body > .tinv-wishlist');
|
660 |
$msg.on('click', '.tinv-close-modal, .tinvwl_button_close, .tinv-overlay', function (e) {
|
@@ -662,97 +611,94 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
662 |
$msg.remove();
|
663 |
});
|
664 |
var closeTimer;
|
665 |
-
|
666 |
if (!closeTimer) {
|
667 |
closeTimer = window.setTimeout(function () {
|
668 |
$msg.remove();
|
669 |
-
|
670 |
if (closeTimer) {
|
671 |
clearTimeout(closeTimer);
|
672 |
}
|
673 |
}, tinvwl_add_to_wishlist.popup_timer);
|
674 |
}
|
675 |
}
|
676 |
-
|
677 |
if (response.redirect) {
|
678 |
return;
|
679 |
}
|
680 |
-
|
681 |
$(document.body).trigger('wc_fragment_refresh');
|
682 |
$('div.tinv-wishlist.woocommerce.tinv-wishlist-clear').replaceWith(response.content);
|
683 |
jQuery.fn.tinvwl_get_wishlist_data();
|
684 |
-
|
685 |
if (response.wishlists_data) {
|
686 |
set_hash(JSON.stringify(response.wishlists_data));
|
687 |
}
|
688 |
});
|
689 |
-
});
|
690 |
|
|
|
691 |
$('body').on('click keydown', 'button[name="tinvwl-action-product_apply"], button[name="tinvwl-action-product_selected"]', function (e) {
|
692 |
if ('keydown' === e.type) {
|
693 |
-
var keyD = e.key !== undefined ? e.key : e.keyCode;
|
|
|
|
|
694 |
// I tested within IE11, Firefox, Chrome, Edge (latest) & all had good support for e.key
|
695 |
|
696 |
if (!('Enter' === keyD || 13 === keyD || 0 <= ['Spacebar', ' '].indexOf(keyD) || 32 === keyD)) {
|
697 |
return;
|
698 |
}
|
699 |
}
|
700 |
-
|
701 |
e.preventDefault();
|
702 |
var products = [];
|
703 |
$('input[name="wishlist_pr[]"]:checked').each(function () {
|
704 |
products.push(this.value);
|
705 |
});
|
706 |
var el = $(this);
|
707 |
-
|
708 |
if (!products.length || 'tinvwl-action-product_selected' !== el.attr('name') && !$('select#tinvwl_product_actions option').filter(':selected').val()) {
|
709 |
alert(window.tinvwl_add_to_wishlist['tinvwl_break_submit']);
|
710 |
return;
|
711 |
}
|
712 |
-
|
713 |
if (el.is('.inited-wishlist-action')) {
|
714 |
return;
|
715 |
}
|
716 |
-
|
717 |
el.addClass('inited-wishlist-action');
|
718 |
var action = '';
|
719 |
-
|
720 |
if ('tinvwl-action-product_selected' === el.attr('name')) {
|
721 |
action = 'add_to_cart_selected';
|
722 |
} else {
|
723 |
action = $('select#tinvwl_product_actions option').filter(':selected').val();
|
724 |
}
|
725 |
-
|
726 |
-
var params = {
|
727 |
'tinvwl-products': products,
|
728 |
'tinvwl-action': action,
|
729 |
'tinvwl-security': tinvwl_add_to_wishlist.nonce,
|
730 |
'tinvwl-paged': el.closest('form').data('tinvwl_paged'),
|
731 |
'tinvwl-sharekey': el.closest('form').data('tinvwl_sharekey')
|
732 |
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
733 |
$.ajax({
|
734 |
url: tinvwl_add_to_wishlist.wc_ajax_url,
|
735 |
method: 'POST',
|
736 |
cache: false,
|
737 |
-
data:
|
738 |
beforeSend: function beforeSend(xhr) {
|
739 |
xhr.setRequestHeader('X-WP-Nonce', tinvwl_add_to_wishlist.nonce);
|
740 |
}
|
741 |
}).done(function (response) {
|
742 |
$('body').trigger('tinvwl_wishlist_ajax_response', [this, response]);
|
743 |
el.removeClass('inited-wishlist-action');
|
744 |
-
|
745 |
if (response.redirect) {
|
746 |
window.location.href = response.redirect;
|
747 |
}
|
748 |
-
|
749 |
if (response.msg) {
|
750 |
var $msg = $(response.msg).eq(0);
|
751 |
-
|
752 |
if (!$('body > .tinv-wishlist').length) {
|
753 |
$('body').append($('<div>').addClass('tinv-wishlist'));
|
754 |
}
|
755 |
-
|
756 |
$('body > .tinv-wishlist').append($msg);
|
757 |
FocusTrap('body > .tinv-wishlist');
|
758 |
$msg.on('click', '.tinv-close-modal, .tinvwl_button_close, .tinv-overlay', function (e) {
|
@@ -760,57 +706,47 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
760 |
$msg.remove();
|
761 |
});
|
762 |
var closeTimer;
|
763 |
-
|
764 |
if (!closeTimer) {
|
765 |
closeTimer = window.setTimeout(function () {
|
766 |
$msg.remove();
|
767 |
-
|
768 |
if (closeTimer) {
|
769 |
clearTimeout(closeTimer);
|
770 |
}
|
771 |
}, tinvwl_add_to_wishlist.popup_timer);
|
772 |
}
|
773 |
}
|
774 |
-
|
775 |
if (response.redirect) {
|
776 |
return;
|
777 |
}
|
778 |
-
|
779 |
if ('add_to_cart_selected' === action) {
|
780 |
$(document.body).trigger('wc_fragment_refresh');
|
781 |
}
|
782 |
-
|
783 |
$('div.tinv-wishlist.woocommerce.tinv-wishlist-clear').replaceWith(response.content);
|
784 |
jQuery.fn.tinvwl_get_wishlist_data();
|
785 |
-
|
786 |
if (response.wishlists_data) {
|
787 |
set_hash(JSON.stringify(response.wishlists_data));
|
788 |
}
|
789 |
});
|
790 |
-
});
|
791 |
|
|
|
792 |
$(document).on('hide_variation', '.variations_form', function (a) {
|
793 |
var e = $('.tinvwl_add_to_wishlist_button:not(.tinvwl-loop)[data-tinv-wl-product="' + $(this).data('product_id') + '"]');
|
794 |
e.attr('data-tinv-wl-productvariation', 0);
|
795 |
-
|
796 |
if (e.length && e.attr('data-tinv-wl-list')) {
|
797 |
var f = JSON.parse(e.attr('data-tinv-wl-list')),
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
for (var i in f) {
|
802 |
if (f[i].hasOwnProperty('in') && Array.isArray(f[i].in) && -1 < (f[i].in || []).indexOf(0)) {
|
803 |
j = true;
|
804 |
}
|
805 |
}
|
806 |
-
|
807 |
e.toggleClass('tinvwl-product-in-list', j).toggleClass('tinvwl-product-make-remove', j && g).attr('data-tinv-wl-action', j && g ? 'remove' : 'addto');
|
808 |
}
|
809 |
-
|
810 |
if (e.length && e.attr('data-tinv-wl-product-stats')) {
|
811 |
e.find('span.tinvwl-product-stats').remove();
|
812 |
var stats = JSON.parse(e.attr('data-tinv-wl-product-stats'));
|
813 |
-
|
814 |
for (var i in stats) {
|
815 |
if (-1 < i.indexOf(0)) {
|
816 |
j = true;
|
@@ -819,7 +755,6 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
819 |
}
|
820 |
}
|
821 |
}
|
822 |
-
|
823 |
if (e.length && !tinvwl_add_to_wishlist.allow_parent_variable) {
|
824 |
a.preventDefault();
|
825 |
e.addClass('disabled-add-wishlist');
|
@@ -828,25 +763,20 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
828 |
$(document).on('show_variation', '.variations_form', function (a, b, d) {
|
829 |
var e = $('.tinvwl_add_to_wishlist_button:not(.tinvwl-loop)[data-tinv-wl-product="' + $(this).data('product_id') + '"]');
|
830 |
e.attr('data-tinv-wl-productvariation', b.variation_id);
|
831 |
-
|
832 |
if (e.length && e.attr('data-tinv-wl-list')) {
|
833 |
var f = JSON.parse(e.attr('data-tinv-wl-list')),
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
for (var i in f) {
|
838 |
if (f[i].hasOwnProperty('in') && Array.isArray(f[i].in) && -1 < (f[i].in || []).indexOf(b.variation_id)) {
|
839 |
j = true;
|
840 |
}
|
841 |
}
|
842 |
-
|
843 |
e.toggleClass('tinvwl-product-in-list', j).toggleClass('tinvwl-product-make-remove', j && g).attr('data-tinv-wl-action', j && g ? 'remove' : 'addto');
|
844 |
}
|
845 |
-
|
846 |
if (e.length && e.attr('data-tinv-wl-product-stats')) {
|
847 |
e.find('span.tinvwl-product-stats').remove();
|
848 |
var stats = JSON.parse(e.attr('data-tinv-wl-product-stats'));
|
849 |
-
|
850 |
for (var i in stats) {
|
851 |
if (-1 < i.indexOf(b.variation_id)) {
|
852 |
j = true;
|
@@ -855,25 +785,25 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
855 |
}
|
856 |
}
|
857 |
}
|
858 |
-
|
859 |
a.preventDefault();
|
860 |
e.removeClass('disabled-add-wishlist');
|
861 |
-
});
|
862 |
|
|
|
863 |
$(window).on('storage onstorage', function (e) {
|
864 |
if (hash_key === e.originalEvent.key && localStorage.getItem(hash_key) !== sessionStorage.getItem(hash_key)) {
|
865 |
if (localStorage.getItem(hash_key)) {
|
866 |
var data = JSON.parse(localStorage.getItem(hash_key));
|
867 |
-
|
868 |
if ('object' === _typeof(data) && null !== data && (data.hasOwnProperty('products') || data.hasOwnProperty('counter'))) {
|
869 |
set_hash(localStorage.getItem(hash_key));
|
870 |
}
|
871 |
}
|
872 |
}
|
873 |
-
});
|
874 |
|
|
|
875 |
var tinvwl_products = [],
|
876 |
-
|
877 |
$('a.tinvwl_add_to_wishlist_button').each(function () {
|
878 |
if ('undefined' !== $(this).data('tinv-wl-product') && $(this).data('tinv-wl-product')) {
|
879 |
tinvwl_products.push($(this).data('tinv-wl-product'));
|
@@ -882,84 +812,44 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
882 |
$('.wishlist_products_counter_number').each(function () {
|
883 |
tinvwl_counter = true;
|
884 |
});
|
885 |
-
|
886 |
-
var rest_request = function rest_request() {
|
887 |
if (tinvwl_products.length || tinvwl_counter) {
|
888 |
-
var
|
889 |
-
'
|
890 |
-
'
|
891 |
-
'tinvwl_request': true
|
892 |
};
|
893 |
-
|
894 |
if (tinvwl_add_to_wishlist.wpml) {
|
895 |
-
|
896 |
}
|
897 |
-
|
898 |
if (tinvwl_add_to_wishlist.wpml_default) {
|
899 |
-
|
900 |
}
|
901 |
-
|
902 |
if ('1' == tinvwl_add_to_wishlist.stats) {
|
903 |
-
|
904 |
}
|
905 |
-
|
906 |
$.ajax({
|
907 |
-
url: tinvwl_add_to_wishlist.
|
908 |
method: 'POST',
|
909 |
-
|
|
|
910 |
beforeSend: function beforeSend(xhr) {
|
911 |
xhr.setRequestHeader('X-WP-Nonce', tinvwl_add_to_wishlist.nonce);
|
912 |
}
|
913 |
}).done(function (response) {
|
914 |
$('body').trigger('tinvwl_wishlist_ajax_response', [this, response]);
|
915 |
-
|
916 |
-
|
917 |
-
});
|
918 |
-
}
|
919 |
-
};
|
920 |
-
|
921 |
-
var custom_ajax = function custom_ajax() {
|
922 |
-
if (tinvwl_products.length || tinvwl_counter) {
|
923 |
-
var params = {};
|
924 |
-
|
925 |
-
if (tinvwl_add_to_wishlist.wpml) {
|
926 |
-
params.lang = tinvwl_add_to_wishlist.wpml;
|
927 |
-
}
|
928 |
-
|
929 |
-
if (tinvwl_add_to_wishlist.wpml_default) {
|
930 |
-
params.lang_default = tinvwl_add_to_wishlist.wpml_default;
|
931 |
-
}
|
932 |
-
|
933 |
-
if ('1' == tinvwl_add_to_wishlist.stats) {
|
934 |
-
params.stats = tinvwl_add_to_wishlist.stats;
|
935 |
-
}
|
936 |
-
|
937 |
-
$.ajax({
|
938 |
-
url: tinvwl_add_to_wishlist.plugin_url + 'includes/api/ajax.php',
|
939 |
-
method: 'POST',
|
940 |
-
data: params,
|
941 |
-
beforeSend: function beforeSend(xhr) {
|
942 |
-
xhr.setRequestHeader('X-WP-Nonce', tinvwl_add_to_wishlist.nonce);
|
943 |
}
|
944 |
-
}).done(function (response) {
|
945 |
-
$('body').trigger('tinvwl_wishlist_ajax_response', [this, response]);
|
946 |
-
set_hash(JSON.stringify(response));
|
947 |
-
mark_products(response);
|
948 |
-
}).fail(function () {
|
949 |
-
rest_request();
|
950 |
});
|
951 |
}
|
952 |
};
|
953 |
-
|
954 |
$.fn.tinvwl_get_wishlist_data = function () {
|
955 |
if ($supports_html5_storage) {
|
956 |
if (tinvwl_add_to_wishlist.update_wishlists_data) {
|
957 |
localStorage.setItem(hash_key, '');
|
958 |
}
|
959 |
-
|
960 |
if (localStorage.getItem(hash_key)) {
|
961 |
var data = JSON.parse(localStorage.getItem(hash_key));
|
962 |
-
|
963 |
if ('object' === _typeof(data) && null !== data && (data.hasOwnProperty('products') || data.hasOwnProperty('counter'))) {
|
964 |
if (!data.hasOwnProperty('lang') && !tinvwl_add_to_wishlist.wpml || tinvwl_add_to_wishlist.wpml && data.lang === tinvwl_add_to_wishlist.wpml) {
|
965 |
mark_products(data);
|
@@ -968,29 +858,26 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
968 |
}
|
969 |
}
|
970 |
}
|
971 |
-
|
972 |
if (tinvwl_add_to_wishlist.block_ajax_wishlists_data) {
|
973 |
return;
|
974 |
}
|
975 |
-
|
976 |
-
custom_ajax();
|
977 |
};
|
978 |
-
|
979 |
$.fn.tinvwl_get_wishlist_data();
|
|
|
980 |
/* Dynamic buttons */
|
981 |
// Create an observer instance
|
982 |
-
|
983 |
var observer = new MutationObserver(function (mutations) {
|
984 |
tinvwl_products = [];
|
985 |
mutations.forEach(function (mutation) {
|
986 |
-
var newNodes = mutation.addedNodes;
|
987 |
|
|
|
988 |
if (null !== newNodes) {
|
989 |
var $nodes = $(newNodes);
|
990 |
$nodes.each(function () {
|
991 |
var $node = $(this),
|
992 |
-
|
993 |
-
|
994 |
if (els.length) {
|
995 |
els.each(function () {
|
996 |
if ('undefined' !== $(this).data('tinv-wl-product') && $(this).data('tinv-wl-product')) {
|
@@ -1001,12 +888,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
1001 |
});
|
1002 |
}
|
1003 |
});
|
1004 |
-
|
1005 |
if (tinvwl_products.length) {
|
1006 |
$.fn.tinvwl_get_wishlist_data();
|
1007 |
}
|
1008 |
-
});
|
1009 |
|
|
|
1010 |
var config = {
|
1011 |
childList: true,
|
1012 |
subtree: true
|
@@ -1014,11 +901,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
1014 |
var targetNode = document.body;
|
1015 |
observer.observe(targetNode, config);
|
1016 |
});
|
1017 |
-
/* Storage Handling */
|
1018 |
|
|
|
1019 |
var $supports_html5_storage = true,
|
1020 |
-
|
1021 |
-
|
1022 |
try {
|
1023 |
$supports_html5_storage = 'sessionStorage' in window && null !== window.sessionStorage;
|
1024 |
window.sessionStorage.setItem('ti', 'test');
|
@@ -1028,31 +914,26 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
1028 |
} catch (err) {
|
1029 |
$supports_html5_storage = false;
|
1030 |
}
|
1031 |
-
|
1032 |
function mark_products(data) {
|
1033 |
var g = '1' == window.tinvwl_add_to_wishlist['simple_flow'];
|
1034 |
-
|
1035 |
if (g || data.stats && '1' == tinvwl_add_to_wishlist.stats) {
|
1036 |
$('a.tinvwl_add_to_wishlist_button').each(function () {
|
1037 |
if (g) {
|
1038 |
$(this).removeClass('tinvwl-product-make-remove').removeClass('tinvwl-product-already-on-wishlist').removeClass('tinvwl-product-in-list').attr('data-tinv-wl-action', 'addto').attr('data-tinv-wl-list', '[]');
|
1039 |
}
|
1040 |
-
|
1041 |
if (data.stats) {
|
1042 |
$(this).find('span.tinvwl-product-stats').remove();
|
1043 |
}
|
1044 |
});
|
1045 |
}
|
1046 |
-
|
1047 |
$('body').trigger('tinvwl_wishlist_mark_products', [data]);
|
1048 |
$.each(data.products, function (i, item) {
|
1049 |
var id = i,
|
1050 |
-
|
1051 |
e.each(function () {
|
1052 |
var vid = parseInt($(this).attr('data-tinv-wl-productvariation')),
|
1053 |
-
|
1054 |
-
|
1055 |
-
|
1056 |
for (var i in item) {
|
1057 |
if (item[i].hasOwnProperty('in') && Array.isArray(item[i].in) && (-1 < (item[i].in || []).indexOf(id) || -1 < (item[i].in || []).indexOf(vid) || vids.some(function (r) {
|
1058 |
return 0 <= (item[i].in || []).indexOf(r);
|
@@ -1060,21 +941,18 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
1060 |
j = true;
|
1061 |
}
|
1062 |
}
|
1063 |
-
|
1064 |
$('body').trigger('tinvwl_wishlist_product_marked', [this, j]);
|
1065 |
$(this).attr('data-tinv-wl-list', JSON.stringify(item)).toggleClass('tinvwl-product-in-list', j).toggleClass('tinvwl-product-make-remove', j && g).attr('data-tinv-wl-action', j && g ? 'remove' : 'addto');
|
1066 |
});
|
1067 |
});
|
1068 |
-
|
1069 |
if (data.stats && '1' == tinvwl_add_to_wishlist.stats) {
|
1070 |
$.each(data.stats, function (i, item) {
|
1071 |
var id = i,
|
1072 |
-
|
1073 |
e.each(function () {
|
1074 |
$(this).attr('data-tinv-wl-product-stats', JSON.stringify(item));
|
1075 |
var vid = parseInt($(this).attr('data-tinv-wl-productvariation')),
|
1076 |
-
|
1077 |
-
|
1078 |
for (var i in item) {
|
1079 |
if (-1 < i.indexOf(vid)) {
|
1080 |
j = true;
|
@@ -1085,12 +963,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
1085 |
});
|
1086 |
});
|
1087 |
}
|
1088 |
-
|
1089 |
update_product_counter(data.counter);
|
1090 |
}
|
1091 |
-
/** Set the hash in both session and local storage */
|
1092 |
-
|
1093 |
|
|
|
1094 |
function set_hash(hash) {
|
1095 |
if ($supports_html5_storage) {
|
1096 |
localStorage.setItem(hash_key, hash);
|
@@ -1098,14 +974,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
1098 |
mark_products(JSON.parse(hash));
|
1099 |
}
|
1100 |
}
|
1101 |
-
|
1102 |
function update_product_counter(counter) {
|
1103 |
if ('1' == window.tinvwl_add_to_wishlist['hide_zero_counter'] && 0 === counter) {
|
1104 |
counter = 'false';
|
1105 |
}
|
1106 |
-
|
1107 |
jQuery('i.wishlist-icon').addClass('added');
|
1108 |
-
|
1109 |
if ('false' !== counter) {
|
1110 |
jQuery('.wishlist_products_counter_number, body.theme-woostify .wishlist-item-count').html(counter);
|
1111 |
jQuery('i.wishlist-icon').attr('data-icon-label', counter);
|
@@ -1113,31 +986,29 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
1113 |
jQuery('.wishlist_products_counter_number, body.theme-woostify .wishlist-item-count').html('').closest('span.wishlist-counter-with-products').removeClass('wishlist-counter-with-products');
|
1114 |
jQuery('i.wishlist-icon').removeAttr('data-icon-label');
|
1115 |
}
|
1116 |
-
|
1117 |
var has_products = !('0' == counter || 'false' == counter);
|
1118 |
jQuery('.wishlist_products_counter').toggleClass('wishlist-counter-with-products', has_products);
|
1119 |
setTimeout(function () {
|
1120 |
jQuery('i.wishlist-icon').removeClass('added');
|
1121 |
}, 500);
|
1122 |
}
|
1123 |
-
|
1124 |
function FocusTrap(el) {
|
1125 |
var inputs = $(el).find('select, input, textarea, button, a').filter(':visible');
|
1126 |
var firstInput = inputs.first();
|
1127 |
var lastInput = inputs.last();
|
1128 |
-
/*set focus on first input*/
|
1129 |
|
|
|
1130 |
firstInput.focus().blur();
|
1131 |
-
/*redirect last tab to first input*/
|
1132 |
|
|
|
1133 |
lastInput.on('keydown', function (e) {
|
1134 |
if (9 === e.which && !e.shiftKey) {
|
1135 |
e.preventDefault();
|
1136 |
firstInput.focus();
|
1137 |
}
|
1138 |
});
|
1139 |
-
/*redirect first shift+tab to last input*/
|
1140 |
|
|
|
1141 |
firstInput.on('keydown', function (e) {
|
1142 |
if (9 === e.which && e.shiftKey) {
|
1143 |
e.preventDefault();
|
@@ -1158,13 +1029,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
1158 |
});
|
1159 |
$('body').on('click', '.social-buttons .social:not(.social-email,.social-whatsapp,.social-clipboard)', function (e) {
|
1160 |
var newWind = window.open($(this).attr('href'), $(this).attr('title'), 'width=420,height=320,resizable=yes,scrollbars=yes,status=yes');
|
1161 |
-
|
1162 |
if (newWind) {
|
1163 |
newWind.focus();
|
1164 |
e.preventDefault();
|
1165 |
}
|
1166 |
});
|
1167 |
-
|
1168 |
if ('undefined' !== typeof ClipboardJS) {
|
1169 |
var clipboard = new ClipboardJS('.social-buttons .social.social-clipboard', {
|
1170 |
text: function text(trigger) {
|
@@ -1175,13 +1044,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
1175 |
showTooltip(e.trigger, tinvwl_add_to_wishlist.tinvwl_clipboard);
|
1176 |
});
|
1177 |
var btns = document.querySelectorAll('.social-buttons .social.social-clipboard');
|
1178 |
-
|
1179 |
for (var i = 0; i < btns.length; i++) {
|
1180 |
btns[i].addEventListener('mouseleave', clearTooltip);
|
1181 |
btns[i].addEventListener('blur', clearTooltip);
|
1182 |
}
|
1183 |
}
|
1184 |
-
|
1185 |
$('body').on('click', '.social-buttons .social.social-clipboard', function (e) {
|
1186 |
e.preventDefault();
|
1187 |
});
|
@@ -1192,24 +1059,20 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
1192 |
});
|
1193 |
$('body').on('click', '.tinv-wishlist .tinvwl-btn-onclick', function (e) {
|
1194 |
var url = $(this).data('url');
|
1195 |
-
|
1196 |
if (url) {
|
1197 |
e.preventDefault();
|
1198 |
window.location = $(this).data('url');
|
1199 |
}
|
1200 |
});
|
1201 |
var navigationButton = $('.tinv-wishlist .navigation-button');
|
1202 |
-
|
1203 |
if (navigationButton.length) {
|
1204 |
navigationButton.each(function () {
|
1205 |
var navigationButtons = $(this).find('> li');
|
1206 |
-
|
1207 |
if (5 > navigationButtons.length) {
|
1208 |
navigationButtons.parent().addClass('tinvwl-btns-count-' + navigationButtons.length);
|
1209 |
}
|
1210 |
});
|
1211 |
}
|
1212 |
-
|
1213 |
$('.tinv-login .showlogin').off('click').on('click', function (e) {
|
1214 |
e.preventDefault();
|
1215 |
$(this).closest('.tinv-login').find('.login').toggle();
|
@@ -1219,12 +1082,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
1219 |
});
|
1220 |
});
|
1221 |
})(jQuery);
|
1222 |
-
|
1223 |
function showTooltip(elem, msg) {
|
1224 |
elem.setAttribute('class', 'social social-clipboard tooltipped tooltipped-s');
|
1225 |
elem.setAttribute('aria-label', msg);
|
1226 |
}
|
1227 |
-
|
1228 |
function clearTooltip(e) {
|
1229 |
e.currentTarget.setAttribute('class', 'social social-clipboard ');
|
1230 |
e.currentTarget.removeAttribute('aria-label');
|
@@ -1244,17 +1105,14 @@ function clearTooltip(e) {
|
|
1244 |
},
|
1245 |
rule: function rule() {
|
1246 |
var form_elements = $(this).parents('form').eq(0).find(s.selector),
|
1247 |
-
|
1248 |
-
|
1249 |
if (0 === form_elements.length) {
|
1250 |
return s.ifempty;
|
1251 |
}
|
1252 |
-
|
1253 |
form_elements.each(function () {
|
1254 |
if (trigger && !s.invert || !trigger && s.invert) {
|
1255 |
return;
|
1256 |
}
|
1257 |
-
|
1258 |
trigger = Boolean(s.validate.call($(this)));
|
1259 |
});
|
1260 |
return trigger;
|
@@ -1264,30 +1122,24 @@ function clearTooltip(e) {
|
|
1264 |
return $(this).each(function () {
|
1265 |
$(this).on('click', function (event) {
|
1266 |
var ss = [];
|
1267 |
-
|
1268 |
if ('undefined' !== typeof $(this).attr('tinvwl_break_submit')) {
|
1269 |
ss = $(this).attr('tinvwl_break_submit').split(',');
|
1270 |
}
|
1271 |
-
|
1272 |
if (-1 !== jQuery.inArray(s.selector, ss)) {
|
1273 |
ss = [];
|
1274 |
}
|
1275 |
-
|
1276 |
if (!s.rule.call($(this)) && 0 === ss.length) {
|
1277 |
alert(window.tinvwl_add_to_wishlist['tinvwl_break_submit']);
|
1278 |
event.preventDefault();
|
1279 |
}
|
1280 |
-
|
1281 |
ss.push(s.selector);
|
1282 |
$(this).attr('tinvwl_break_submit', ss);
|
1283 |
-
|
1284 |
if (s.rule.call($(this))) {
|
1285 |
$(this).removeAttr('tinvwl_break_submit');
|
1286 |
}
|
1287 |
});
|
1288 |
});
|
1289 |
};
|
1290 |
-
|
1291 |
$(document).ready(function () {
|
1292 |
// Wishlist table bulk action checkbox
|
1293 |
$('body').on('click', '.global-cb', function () {
|
1 |
"use strict";
|
2 |
|
3 |
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
|
4 |
// Add to wishlist
|
5 |
(function ($) {
|
6 |
//Add to wishlist main function.
|
22 |
if (!$('body > .tinv-wishlist').length) {
|
23 |
$('body').append($('<div>').addClass('tinv-wishlist'));
|
24 |
}
|
|
|
25 |
$(this).appendTo('body > .tinv-wishlist');
|
26 |
},
|
27 |
onCreateWishList: function onCreateWishList(wishlist) {
|
41 |
if ($(this).is('.disabled-add-wishlist')) {
|
42 |
return false;
|
43 |
}
|
|
|
44 |
if ($(this).is('.ftinvwl-animated')) {
|
45 |
$(this).addClass('ftinvwl-pulse');
|
46 |
}
|
|
|
47 |
if (this.tinvwl_dialog) {
|
48 |
this.tinvwl_dialog.show_list.call(this);
|
49 |
} else {
|
55 |
},
|
56 |
filterProductAlreadyIn: function filterProductAlreadyIn(WList) {
|
57 |
var WList = WList || [],
|
58 |
+
data = {};
|
59 |
$('form.cart[method=post], .woocommerce-variation-add-to-cart, form.vtajaxform[method=post]').find('input, select').each(function () {
|
60 |
var name_elm = $(this).attr('name'),
|
61 |
+
type_elm = $(this).attr('type'),
|
62 |
+
value_elm = $(this).val();
|
|
|
63 |
if ('checkbox' === type_elm || 'radio' === type_elm) {
|
64 |
if ($(this).is(':checked')) {
|
65 |
data['form' + name_elm] = value_elm;
|
74 |
var number = parseInt(data);
|
75 |
return 0 <= wishlist.in.indexOf(number);
|
76 |
}
|
|
|
77 |
return wishlist.in;
|
78 |
});
|
79 |
},
|
83 |
WList = s.filterProductAlreadyIn.call(this, WList) || WList;
|
84 |
$(this).parent().parent().find('.already-in').remove();
|
85 |
var text = '';
|
|
|
86 |
switch (WList.length) {
|
87 |
case 0:
|
88 |
break;
|
|
|
89 |
default:
|
90 |
var text = $('<ul>');
|
91 |
$.each(WList, function (k, wishlist) {
|
95 |
});
|
96 |
break;
|
97 |
}
|
|
|
98 |
if (text.length) {
|
99 |
$(this).closest('.tinv-modal-inner').find('img').after($('<div>').addClass('already-in').html(s.text_already_in + ' ').append(text));
|
100 |
}
|
104 |
if (s.redirectTimer) {
|
105 |
clearTimeout(s.redirectTimer);
|
106 |
}
|
|
|
107 |
s.redirectTimer = window.setTimeout(function () {
|
108 |
window.location.href = url;
|
109 |
}, 4000);
|
116 |
if (!html) {
|
117 |
return false;
|
118 |
}
|
|
|
119 |
var $msg = $(html).eq(0);
|
|
|
120 |
if (!$('body > .tinv-wishlist').length) {
|
121 |
$('body').append($('<div>').addClass('tinv-wishlist'));
|
122 |
}
|
|
|
123 |
$('body > .tinv-wishlist').append($msg);
|
124 |
FocusTrap('body > .tinv-wishlist');
|
|
|
125 |
if (!s.redirectTimer) {
|
126 |
s.removeTimer = window.setTimeout(function () {
|
127 |
$msg.remove();
|
|
|
128 |
if (s.redirectTimer) {
|
129 |
clearTimeout(s.redirectTimer);
|
130 |
}
|
131 |
}, tinvwl_add_to_wishlist.popup_timer);
|
132 |
}
|
|
|
133 |
$msg.on('click', '.tinv-close-modal, .tinvwl_button_close, .tinv-overlay', function (e) {
|
134 |
e.preventDefault();
|
135 |
$msg.remove();
|
|
|
136 |
if (s.redirectTimer) {
|
137 |
clearTimeout(s.redirectTimer);
|
138 |
}
|
|
|
139 |
if (s.removeTimer) {
|
140 |
clearTimeout(s.removeTimer);
|
141 |
}
|
151 |
}
|
152 |
}
|
153 |
};
|
|
|
154 |
sd.onActionProduct = function (id, name) {
|
155 |
var data = {
|
156 |
+
form: {},
|
157 |
+
tinv_wishlist_id: id || '',
|
158 |
+
tinv_wishlist_name: name || '',
|
159 |
+
product_type: $(this).attr('data-tinv-wl-producttype'),
|
160 |
+
product_id: $(this).attr('data-tinv-wl-product') || 0,
|
161 |
+
product_variation: $(this).attr('data-tinv-wl-productvariation') || 0,
|
162 |
+
product_action: $(this).attr('data-tinv-wl-action') || 'addto',
|
163 |
+
redirect: window.location.href
|
164 |
+
},
|
165 |
+
a = this,
|
166 |
+
formEl = [],
|
167 |
+
formData = new FormData();
|
|
|
168 |
if (tinvwl_add_to_wishlist.wpml) {
|
169 |
data.lang = tinvwl_add_to_wishlist.wpml;
|
170 |
}
|
|
|
171 |
if (tinvwl_add_to_wishlist.wpml_default) {
|
172 |
data.lang_default = tinvwl_add_to_wishlist.wpml_default;
|
173 |
}
|
|
|
174 |
if ('1' == tinvwl_add_to_wishlist.stats) {
|
175 |
data.stats = tinvwl_add_to_wishlist.stats;
|
176 |
}
|
|
|
177 |
$('form.cart[method=post][data-product_id="' + $(this).attr('data-tinv-wl-product') + '"], form.vtajaxform[method=post][data-product_id="' + $(this).attr('data-tinv-wl-product') + '"]').each(function () {
|
178 |
formEl.push($(this));
|
179 |
});
|
|
|
180 |
if (!formEl.length) {
|
181 |
$(a).closest('form.cart[method=post], form.vtajaxform[method=post]').each(function () {
|
182 |
formEl.push($(this));
|
183 |
});
|
|
|
184 |
if (!formEl.length) {
|
185 |
formEl.push($('form.cart[method=post]'));
|
186 |
}
|
187 |
}
|
|
|
188 |
$('.tinv-wraper[data-tinvwl_product_id="' + $(this).attr('data-tinv-wl-product') + '"]').each(function () {
|
189 |
formEl.push($(this));
|
190 |
});
|
191 |
$.each(formEl, function (index, element) {
|
192 |
$(element).find('input:not(:disabled), select:not(:disabled), textarea:not(:disabled)').each(function () {
|
193 |
var name_elm = $(this).attr('name'),
|
194 |
+
type_elm = $(this).attr('type'),
|
195 |
+
value_elm = $(this).val(),
|
196 |
+
count = 10,
|
197 |
+
ti_merge_value = function ti_merge_value(o1, o2) {
|
198 |
+
if ('object' === _typeof(o2)) {
|
199 |
+
if ('undefined' === typeof o1) {
|
200 |
+
o1 = {};
|
201 |
+
}
|
202 |
+
for (var i in o2) {
|
203 |
+
if ('' === i) {
|
204 |
+
var j = -1;
|
205 |
+
for (j in o1) {
|
206 |
+
j = j;
|
207 |
+
}
|
208 |
+
j = parseInt(j) + 1;
|
209 |
+
o1[j] = ti_merge_value(o1[i], o2[i]);
|
210 |
+
} else {
|
211 |
+
o1[i] = ti_merge_value(o1[i], o2[i]);
|
212 |
}
|
|
|
|
|
|
|
|
|
|
|
213 |
}
|
214 |
+
return o1;
|
215 |
+
} else {
|
216 |
+
return o2;
|
217 |
}
|
218 |
+
};
|
|
|
|
|
|
|
|
|
|
|
|
|
219 |
if ('button' === type_elm || 'undefined' == typeof name_elm) {
|
220 |
return;
|
221 |
}
|
|
|
222 |
while (/^(.+)\[([^\[\]]*?)\]$/.test(name_elm) && 0 < count) {
|
223 |
var n_name = name_elm.match(/^(.+)\[([^\[\]]*?)\]$/);
|
|
|
224 |
if (3 === n_name.length) {
|
225 |
var _value_elm = {};
|
226 |
_value_elm[n_name[2]] = value_elm;
|
227 |
value_elm = _value_elm;
|
228 |
}
|
|
|
229 |
name_elm = n_name[1];
|
230 |
count--;
|
231 |
}
|
|
|
232 |
if ('file' === type_elm) {
|
233 |
var file_data = $(this)[0].files;
|
|
|
234 |
if (file_data) {
|
235 |
formData.append(name_elm, file_data[0]);
|
236 |
}
|
237 |
}
|
|
|
238 |
if ('checkbox' === type_elm || 'radio' === type_elm) {
|
239 |
if ($(this).is(':checked')) {
|
240 |
if (!value_elm.length && 'object' !== _typeof(value_elm)) {
|
241 |
value_elm = true;
|
242 |
}
|
|
|
243 |
data.form[name_elm] = ti_merge_value(data.form[name_elm], value_elm);
|
244 |
}
|
245 |
} else {
|
254 |
if ('object' === _typeof(v)) {
|
255 |
v = JSON.stringify(v);
|
256 |
}
|
|
|
257 |
formData.append(key + '[' + k + ']', v);
|
258 |
});
|
259 |
} else {
|
269 |
}).done(function (body) {
|
270 |
$('body').trigger('tinvwl_wishlist_ajax_response', [this, body]);
|
271 |
s.onDialogHide.call(a.tinvwl_dialog, a);
|
|
|
272 |
if ('object' === _typeof(body)) {
|
273 |
for (var k in body) {
|
274 |
if ('function' === typeof s.onAction[k]) {
|
282 |
}
|
283 |
});
|
284 |
};
|
|
|
285 |
var s = $.extend(true, {}, sd, so);
|
286 |
return $(this).each(function () {
|
287 |
if (!$(this).attr('data-tinv-wl-list')) {
|
288 |
return false;
|
289 |
}
|
|
|
290 |
if (s.dialogbox) {
|
291 |
if (s.dialogbox.length) {
|
292 |
this.tinvwl_dialog = s.dialogbox;
|
293 |
}
|
294 |
}
|
|
|
295 |
if (!this.tinvwl_dialog) {
|
296 |
this.tinvwl_dialog = s.onGetDialogBox.call(this);
|
297 |
}
|
|
|
298 |
if (!this.tinvwl_dialog) {
|
299 |
var _tinvwl_dialog = $(this).nextAll(s.class.dialogbox).eq(0);
|
|
|
300 |
if (_tinvwl_dialog.length) {
|
301 |
this.tinvwl_dialog = _tinvwl_dialog;
|
302 |
}
|
303 |
}
|
|
|
304 |
if (this.tinvwl_dialog) {
|
305 |
s.onPrepareDialogBox.call(this.tinvwl_dialog);
|
|
|
306 |
if ('function' !== typeof this.tinvwl_dialog.update_list) {
|
307 |
this.tinvwl_dialog.update_list = function (WL) {
|
308 |
var $select = $(this).find(s.class.select).eq(0);
|
311 |
$.each(WL, function (k, v) {
|
312 |
s.onCreateWishList.call($select, v);
|
313 |
});
|
|
|
314 |
if (s.text_create) {
|
315 |
s.onCreateWishList.call($select, {
|
316 |
ID: '',
|
318 |
in: false
|
319 |
});
|
320 |
}
|
|
|
321 |
s.onMultiProductAlreadyIn.call($select, WL);
|
322 |
s.onSelectWishList.call($select, WL);
|
323 |
$(this).find(s.class.newtitle).toggle('' === $select.val());
|
324 |
};
|
325 |
}
|
|
|
326 |
if ('function' !== typeof this.tinvwl_dialog.show_list) {
|
327 |
this.tinvwl_dialog.show_list = function () {
|
328 |
var WList = JSON.parse($(this).attr('data-tinv-wl-list')) || [];
|
|
|
329 |
if (WList.length) {
|
330 |
WList = s.onPrepareList.call(WList) || WList;
|
331 |
this.tinvwl_dialog.update_list(WList);
|
335 |
}
|
336 |
};
|
337 |
}
|
|
|
338 |
var a = this;
|
339 |
$(this.tinvwl_dialog).find(s.class.dialogbutton).off('click').on('click', function () {
|
340 |
var b = $(a.tinvwl_dialog).find(s.class.select),
|
341 |
+
c = $(a.tinvwl_dialog).find(s.class.newtitle),
|
342 |
+
d;
|
|
|
343 |
if (b.val() || c.val()) {
|
344 |
s.onActionProduct.call(a, b.val(), c.val());
|
345 |
} else {
|
351 |
}
|
352 |
});
|
353 |
}
|
|
|
354 |
$(this).off('click').on('click', s.onClick);
|
355 |
s.onInited.call(this, s);
|
356 |
});
|
357 |
};
|
|
|
358 |
$(document).ready(function () {
|
359 |
// Add to wishlist button click
|
360 |
$('body').on('click keydown', '.tinvwl_add_to_wishlist_button', function (e) {
|
361 |
if ('keydown' === e.type) {
|
362 |
+
var keyD = e.key !== undefined ? e.key : e.keyCode;
|
363 |
+
|
364 |
+
// e.key && e.keycode have mixed support - keycode is deprecated but support is greater than e.key
|
365 |
// I tested within IE11, Firefox, Chrome, Edge (latest) & all had good support for e.key
|
366 |
|
367 |
if (!('Enter' === keyD || 13 === keyD || 0 <= ['Spacebar', ' '].indexOf(keyD) || 32 === keyD)) {
|
368 |
return;
|
369 |
}
|
|
|
370 |
e.preventDefault();
|
371 |
}
|
|
|
372 |
$('body').trigger('tinvwl_add_to_wishlist_button_click', [this]);
|
|
|
373 |
if ($(this).is('.disabled-add-wishlist')) {
|
374 |
e.preventDefault();
|
375 |
window.alert(tinvwl_add_to_wishlist.i18n_make_a_selection_text);
|
376 |
return;
|
377 |
}
|
|
|
378 |
if ($(this).is('.inited-add-wishlist')) {
|
379 |
return;
|
380 |
}
|
|
|
381 |
$(this).tinvwl_to_wishlist({
|
382 |
onInited: function onInited(s) {
|
383 |
$(this).addClass('inited-add-wishlist');
|
384 |
s.onClick.call(this);
|
385 |
}
|
386 |
});
|
387 |
+
});
|
388 |
|
389 |
+
//Remove button ajax
|
390 |
$('body').on('click keydown', 'button[name="tinvwl-remove"]', function (e) {
|
391 |
if ('keydown' === e.type) {
|
392 |
+
var keyD = e.key !== undefined ? e.key : e.keyCode;
|
393 |
+
|
394 |
+
// e.key && e.keycode have mixed support - keycode is deprecated but support is greater than e.key
|
395 |
// I tested within IE11, Firefox, Chrome, Edge (latest) & all had good support for e.key
|
396 |
|
397 |
if (!('Enter' === keyD || 13 === keyD || 0 <= ['Spacebar', ' '].indexOf(keyD) || 32 === keyD)) {
|
398 |
return;
|
399 |
}
|
400 |
}
|
|
|
401 |
e.preventDefault();
|
402 |
var el = $(this);
|
|
|
403 |
if (el.is('.inited-wishlist-action')) {
|
404 |
return;
|
405 |
}
|
|
|
406 |
el.addClass('inited-wishlist-action');
|
407 |
+
var data = {
|
408 |
'tinvwl-product_id': el.val(),
|
409 |
'tinvwl-action': 'remove',
|
410 |
'tinvwl-security': tinvwl_add_to_wishlist.nonce,
|
411 |
'tinvwl-paged': el.closest('form').data('tinvwl_paged'),
|
412 |
'tinvwl-sharekey': el.closest('form').data('tinvwl_sharekey')
|
413 |
};
|
414 |
+
if (tinvwl_add_to_wishlist.wpml) {
|
415 |
+
data.lang = tinvwl_add_to_wishlist.wpml;
|
416 |
+
}
|
417 |
+
if (tinvwl_add_to_wishlist.wpml_default) {
|
418 |
+
data.lang_default = tinvwl_add_to_wishlist.wpml_default;
|
419 |
+
}
|
420 |
+
if ('1' == tinvwl_add_to_wishlist.stats) {
|
421 |
+
data.stats = tinvwl_add_to_wishlist.stats;
|
422 |
+
}
|
423 |
$.ajax({
|
424 |
url: tinvwl_add_to_wishlist.wc_ajax_url,
|
425 |
method: 'POST',
|
426 |
cache: false,
|
427 |
+
data: data,
|
428 |
beforeSend: function beforeSend(xhr) {
|
429 |
xhr.setRequestHeader('X-WP-Nonce', tinvwl_add_to_wishlist.nonce);
|
430 |
}
|
431 |
}).done(function (response) {
|
432 |
$('body').trigger('tinvwl_wishlist_ajax_response', [this, response]);
|
433 |
el.removeClass('inited-wishlist-action');
|
|
|
434 |
if (response.msg) {
|
435 |
var $msg = $(response.msg).eq(0);
|
|
|
436 |
if (!$('body > .tinv-wishlist').length) {
|
437 |
$('body').append($('<div>').addClass('tinv-wishlist'));
|
438 |
}
|
|
|
439 |
$('body > .tinv-wishlist').append($msg);
|
440 |
FocusTrap('body > .tinv-wishlist');
|
441 |
$msg.on('click', '.tinv-close-modal, .tinvwl_button_close, .tinv-overlay', function (e) {
|
443 |
$msg.remove();
|
444 |
});
|
445 |
var closeTimer;
|
|
|
446 |
if (!closeTimer) {
|
447 |
closeTimer = window.setTimeout(function () {
|
448 |
$msg.remove();
|
|
|
449 |
if (closeTimer) {
|
450 |
clearTimeout(closeTimer);
|
451 |
}
|
452 |
}, tinvwl_add_to_wishlist.popup_timer);
|
453 |
}
|
454 |
}
|
|
|
455 |
if (response.status) {
|
456 |
$('div.tinv-wishlist.woocommerce.tinv-wishlist-clear').replaceWith(response.content);
|
457 |
$('.tinvwl-break-input').tinvwl_break_submit({
|
465 |
});
|
466 |
jQuery.fn.tinvwl_get_wishlist_data();
|
467 |
}
|
|
|
468 |
if (response.wishlists_data) {
|
469 |
set_hash(JSON.stringify(response.wishlists_data));
|
470 |
}
|
471 |
});
|
472 |
+
});
|
473 |
|
474 |
+
//Add to cart button ajax
|
475 |
$('body').on('click keydown', 'button[name="tinvwl-add-to-cart"]', function (e) {
|
476 |
if ('keydown' === e.type) {
|
477 |
+
var keyD = e.key !== undefined ? e.key : e.keyCode;
|
478 |
+
|
479 |
+
// e.key && e.keycode have mixed support - keycode is deprecated but support is greater than e.key
|
480 |
// I tested within IE11, Firefox, Chrome, Edge (latest) & all had good support for e.key
|
481 |
|
482 |
if (!('Enter' === keyD || 13 === keyD || 0 <= ['Spacebar', ' '].indexOf(keyD) || 32 === keyD)) {
|
483 |
return;
|
484 |
}
|
485 |
}
|
|
|
486 |
e.preventDefault();
|
487 |
var el = $(this);
|
|
|
488 |
if (el.is('.inited-wishlist-action')) {
|
489 |
return;
|
490 |
}
|
|
|
491 |
el.addClass('inited-wishlist-action');
|
492 |
+
var data = {
|
493 |
'tinvwl-product_id': el.val(),
|
494 |
'tinvwl-action': 'add_to_cart_single',
|
495 |
'tinvwl-security': tinvwl_add_to_wishlist.nonce,
|
496 |
'tinvwl-paged': el.closest('form').data('tinvwl_paged'),
|
497 |
'tinvwl-sharekey': el.closest('form').data('tinvwl_sharekey')
|
498 |
};
|
499 |
+
if (tinvwl_add_to_wishlist.wpml) {
|
500 |
+
data.lang = tinvwl_add_to_wishlist.wpml;
|
501 |
+
}
|
502 |
+
if (tinvwl_add_to_wishlist.wpml_default) {
|
503 |
+
data.lang_default = tinvwl_add_to_wishlist.wpml_default;
|
504 |
+
}
|
505 |
+
if ('1' == tinvwl_add_to_wishlist.stats) {
|
506 |
+
data.stats = tinvwl_add_to_wishlist.stats;
|
507 |
+
}
|
508 |
$.ajax({
|
509 |
url: tinvwl_add_to_wishlist.wc_ajax_url,
|
510 |
method: 'POST',
|
511 |
cache: false,
|
512 |
+
data: data,
|
513 |
beforeSend: function beforeSend(xhr) {
|
514 |
xhr.setRequestHeader('X-WP-Nonce', tinvwl_add_to_wishlist.nonce);
|
515 |
}
|
516 |
}).done(function (response) {
|
517 |
$('body').trigger('tinvwl_wishlist_ajax_response', [this, response]);
|
518 |
el.removeClass('inited-wishlist-action');
|
|
|
519 |
if (response.redirect) {
|
520 |
window.location.href = response.redirect;
|
521 |
}
|
|
|
522 |
if (response.msg) {
|
523 |
var $msg = $(response.msg).eq(0);
|
|
|
524 |
if (!$('body > .tinv-wishlist').length) {
|
525 |
$('body').append($('<div>').addClass('tinv-wishlist'));
|
526 |
}
|
|
|
527 |
$('body > .tinv-wishlist').append($msg);
|
528 |
FocusTrap('body > .tinv-wishlist');
|
529 |
$msg.on('click', '.tinv-close-modal, .tinvwl_button_close, .tinv-overlay', function (e) {
|
531 |
$msg.remove();
|
532 |
});
|
533 |
var closeTimer;
|
|
|
534 |
if (!closeTimer) {
|
535 |
closeTimer = window.setTimeout(function () {
|
536 |
$msg.remove();
|
|
|
537 |
if (closeTimer) {
|
538 |
clearTimeout(closeTimer);
|
539 |
}
|
540 |
}, tinvwl_add_to_wishlist.popup_timer);
|
541 |
}
|
542 |
}
|
|
|
543 |
if (response.redirect) {
|
544 |
return;
|
545 |
}
|
|
|
546 |
$(document.body).trigger('wc_fragment_refresh');
|
547 |
$('div.tinv-wishlist.woocommerce.tinv-wishlist-clear').replaceWith(response.content);
|
548 |
jQuery.fn.tinvwl_get_wishlist_data();
|
|
|
549 |
if (response.wishlists_data) {
|
550 |
set_hash(JSON.stringify(response.wishlists_data));
|
551 |
}
|
552 |
});
|
553 |
+
});
|
554 |
|
555 |
+
//Add all to cart button ajax
|
556 |
$('body').on('click keydown', 'button[name="tinvwl-action-product_all"]', function (e) {
|
557 |
if ('keydown' === e.type) {
|
558 |
+
var keyD = e.key !== undefined ? e.key : e.keyCode;
|
559 |
+
|
560 |
+
// e.key && e.keycode have mixed support - keycode is deprecated but support is greater than e.key
|
561 |
// I tested within IE11, Firefox, Chrome, Edge (latest) & all had good support for e.key
|
562 |
|
563 |
if (!('Enter' === keyD || 13 === keyD || 0 <= ['Spacebar', ' '].indexOf(keyD) || 32 === keyD)) {
|
564 |
return;
|
565 |
}
|
566 |
}
|
|
|
567 |
e.preventDefault();
|
568 |
var el = $(this);
|
|
|
569 |
if (el.is('.inited-wishlist-action')) {
|
570 |
return;
|
571 |
}
|
|
|
572 |
el.addClass('inited-wishlist-action');
|
573 |
+
var data = {
|
574 |
'tinvwl-action': 'add_to_cart_all',
|
575 |
'tinvwl-security': tinvwl_add_to_wishlist.nonce,
|
576 |
'tinvwl-paged': el.closest('form').data('tinvwl_paged'),
|
577 |
'tinvwl-sharekey': el.closest('form').data('tinvwl_sharekey')
|
578 |
};
|
579 |
+
if (tinvwl_add_to_wishlist.wpml) {
|
580 |
+
data.lang = tinvwl_add_to_wishlist.wpml;
|
581 |
+
}
|
582 |
+
if (tinvwl_add_to_wishlist.wpml_default) {
|
583 |
+
data.lang_default = tinvwl_add_to_wishlist.wpml_default;
|
584 |
+
}
|
585 |
+
if ('1' == tinvwl_add_to_wishlist.stats) {
|
586 |
+
data.stats = tinvwl_add_to_wishlist.stats;
|
587 |
+
}
|
588 |
$.ajax({
|
589 |
url: tinvwl_add_to_wishlist.wc_ajax_url,
|
590 |
method: 'POST',
|
591 |
cache: false,
|
592 |
+
data: data,
|
593 |
beforeSend: function beforeSend(xhr) {
|
594 |
xhr.setRequestHeader('X-WP-Nonce', tinvwl_add_to_wishlist.nonce);
|
595 |
}
|
596 |
}).done(function (response) {
|
597 |
$('body').trigger('tinvwl_wishlist_ajax_response', [this, response]);
|
598 |
el.removeClass('inited-wishlist-action');
|
|
|
599 |
if (response.redirect) {
|
600 |
window.location.href = response.redirect;
|
601 |
}
|
|
|
602 |
if (response.msg) {
|
603 |
var $msg = $(response.msg).eq(0);
|
|
|
604 |
if (!$('body > .tinv-wishlist').length) {
|
605 |
$('body').append($('<div>').addClass('tinv-wishlist'));
|
606 |
}
|
|
|
607 |
$('body > .tinv-wishlist').append($msg);
|
608 |
FocusTrap('body > .tinv-wishlist');
|
609 |
$msg.on('click', '.tinv-close-modal, .tinvwl_button_close, .tinv-overlay', function (e) {
|
611 |
$msg.remove();
|
612 |
});
|
613 |
var closeTimer;
|
|
|
614 |
if (!closeTimer) {
|
615 |
closeTimer = window.setTimeout(function () {
|
616 |
$msg.remove();
|
|
|
617 |
if (closeTimer) {
|
618 |
clearTimeout(closeTimer);
|
619 |
}
|
620 |
}, tinvwl_add_to_wishlist.popup_timer);
|
621 |
}
|
622 |
}
|
|
|
623 |
if (response.redirect) {
|
624 |
return;
|
625 |
}
|
|
|
626 |
$(document.body).trigger('wc_fragment_refresh');
|
627 |
$('div.tinv-wishlist.woocommerce.tinv-wishlist-clear').replaceWith(response.content);
|
628 |
jQuery.fn.tinvwl_get_wishlist_data();
|
|
|
629 |
if (response.wishlists_data) {
|
630 |
set_hash(JSON.stringify(response.wishlists_data));
|
631 |
}
|
632 |
});
|
633 |
+
});
|
634 |
|
635 |
+
//Bulk action button ajax
|
636 |
$('body').on('click keydown', 'button[name="tinvwl-action-product_apply"], button[name="tinvwl-action-product_selected"]', function (e) {
|
637 |
if ('keydown' === e.type) {
|
638 |
+
var keyD = e.key !== undefined ? e.key : e.keyCode;
|
639 |
+
|
640 |
+
// e.key && e.keycode have mixed support - keycode is deprecated but support is greater than e.key
|
641 |
// I tested within IE11, Firefox, Chrome, Edge (latest) & all had good support for e.key
|
642 |
|
643 |
if (!('Enter' === keyD || 13 === keyD || 0 <= ['Spacebar', ' '].indexOf(keyD) || 32 === keyD)) {
|
644 |
return;
|
645 |
}
|
646 |
}
|
|
|
647 |
e.preventDefault();
|
648 |
var products = [];
|
649 |
$('input[name="wishlist_pr[]"]:checked').each(function () {
|
650 |
products.push(this.value);
|
651 |
});
|
652 |
var el = $(this);
|
|
|
653 |
if (!products.length || 'tinvwl-action-product_selected' !== el.attr('name') && !$('select#tinvwl_product_actions option').filter(':selected').val()) {
|
654 |
alert(window.tinvwl_add_to_wishlist['tinvwl_break_submit']);
|
655 |
return;
|
656 |
}
|
|
|
657 |
if (el.is('.inited-wishlist-action')) {
|
658 |
return;
|
659 |
}
|
|
|
660 |
el.addClass('inited-wishlist-action');
|
661 |
var action = '';
|
|
|
662 |
if ('tinvwl-action-product_selected' === el.attr('name')) {
|
663 |
action = 'add_to_cart_selected';
|
664 |
} else {
|
665 |
action = $('select#tinvwl_product_actions option').filter(':selected').val();
|
666 |
}
|
667 |
+
var data = {
|
|
|
668 |
'tinvwl-products': products,
|
669 |
'tinvwl-action': action,
|
670 |
'tinvwl-security': tinvwl_add_to_wishlist.nonce,
|
671 |
'tinvwl-paged': el.closest('form').data('tinvwl_paged'),
|
672 |
'tinvwl-sharekey': el.closest('form').data('tinvwl_sharekey')
|
673 |
};
|
674 |
+
if (tinvwl_add_to_wishlist.wpml) {
|
675 |
+
data.lang = tinvwl_add_to_wishlist.wpml;
|
676 |
+
}
|
677 |
+
if (tinvwl_add_to_wishlist.wpml_default) {
|
678 |
+
data.lang_default = tinvwl_add_to_wishlist.wpml_default;
|
679 |
+
}
|
680 |
+
if ('1' == tinvwl_add_to_wishlist.stats) {
|
681 |
+
data.stats = tinvwl_add_to_wishlist.stats;
|
682 |
+
}
|
683 |
$.ajax({
|
684 |
url: tinvwl_add_to_wishlist.wc_ajax_url,
|
685 |
method: 'POST',
|
686 |
cache: false,
|
687 |
+
data: data,
|
688 |
beforeSend: function beforeSend(xhr) {
|
689 |
xhr.setRequestHeader('X-WP-Nonce', tinvwl_add_to_wishlist.nonce);
|
690 |
}
|
691 |
}).done(function (response) {
|
692 |
$('body').trigger('tinvwl_wishlist_ajax_response', [this, response]);
|
693 |
el.removeClass('inited-wishlist-action');
|
|
|
694 |
if (response.redirect) {
|
695 |
window.location.href = response.redirect;
|
696 |
}
|
|
|
697 |
if (response.msg) {
|
698 |
var $msg = $(response.msg).eq(0);
|
|
|
699 |
if (!$('body > .tinv-wishlist').length) {
|
700 |
$('body').append($('<div>').addClass('tinv-wishlist'));
|
701 |
}
|
|
|
702 |
$('body > .tinv-wishlist').append($msg);
|
703 |
FocusTrap('body > .tinv-wishlist');
|
704 |
$msg.on('click', '.tinv-close-modal, .tinvwl_button_close, .tinv-overlay', function (e) {
|
706 |
$msg.remove();
|
707 |
});
|
708 |
var closeTimer;
|
|
|
709 |
if (!closeTimer) {
|
710 |
closeTimer = window.setTimeout(function () {
|
711 |
$msg.remove();
|
|
|
712 |
if (closeTimer) {
|
713 |
clearTimeout(closeTimer);
|
714 |
}
|
715 |
}, tinvwl_add_to_wishlist.popup_timer);
|
716 |
}
|
717 |
}
|
|
|
718 |
if (response.redirect) {
|
719 |
return;
|
720 |
}
|
|
|
721 |
if ('add_to_cart_selected' === action) {
|
722 |
$(document.body).trigger('wc_fragment_refresh');
|
723 |
}
|
|
|
724 |
$('div.tinv-wishlist.woocommerce.tinv-wishlist-clear').replaceWith(response.content);
|
725 |
jQuery.fn.tinvwl_get_wishlist_data();
|
|
|
726 |
if (response.wishlists_data) {
|
727 |
set_hash(JSON.stringify(response.wishlists_data));
|
728 |
}
|
729 |
});
|
730 |
+
});
|
731 |
|
732 |
+
// Disable add to wishlist button if variations not selected
|
733 |
$(document).on('hide_variation', '.variations_form', function (a) {
|
734 |
var e = $('.tinvwl_add_to_wishlist_button:not(.tinvwl-loop)[data-tinv-wl-product="' + $(this).data('product_id') + '"]');
|
735 |
e.attr('data-tinv-wl-productvariation', 0);
|
|
|
736 |
if (e.length && e.attr('data-tinv-wl-list')) {
|
737 |
var f = JSON.parse(e.attr('data-tinv-wl-list')),
|
738 |
+
j = false,
|
739 |
+
g = '1' == window.tinvwl_add_to_wishlist['simple_flow'];
|
|
|
740 |
for (var i in f) {
|
741 |
if (f[i].hasOwnProperty('in') && Array.isArray(f[i].in) && -1 < (f[i].in || []).indexOf(0)) {
|
742 |
j = true;
|
743 |
}
|
744 |
}
|
|
|
745 |
e.toggleClass('tinvwl-product-in-list', j).toggleClass('tinvwl-product-make-remove', j && g).attr('data-tinv-wl-action', j && g ? 'remove' : 'addto');
|
746 |
}
|
|
|
747 |
if (e.length && e.attr('data-tinv-wl-product-stats')) {
|
748 |
e.find('span.tinvwl-product-stats').remove();
|
749 |
var stats = JSON.parse(e.attr('data-tinv-wl-product-stats'));
|
|
|
750 |
for (var i in stats) {
|
751 |
if (-1 < i.indexOf(0)) {
|
752 |
j = true;
|
755 |
}
|
756 |
}
|
757 |
}
|
|
|
758 |
if (e.length && !tinvwl_add_to_wishlist.allow_parent_variable) {
|
759 |
a.preventDefault();
|
760 |
e.addClass('disabled-add-wishlist');
|
763 |
$(document).on('show_variation', '.variations_form', function (a, b, d) {
|
764 |
var e = $('.tinvwl_add_to_wishlist_button:not(.tinvwl-loop)[data-tinv-wl-product="' + $(this).data('product_id') + '"]');
|
765 |
e.attr('data-tinv-wl-productvariation', b.variation_id);
|
|
|
766 |
if (e.length && e.attr('data-tinv-wl-list')) {
|
767 |
var f = JSON.parse(e.attr('data-tinv-wl-list')),
|
768 |
+
j = false,
|
769 |
+
g = '1' == window.tinvwl_add_to_wishlist['simple_flow'];
|
|
|
770 |
for (var i in f) {
|
771 |
if (f[i].hasOwnProperty('in') && Array.isArray(f[i].in) && -1 < (f[i].in || []).indexOf(b.variation_id)) {
|
772 |
j = true;
|
773 |
}
|
774 |
}
|
|
|
775 |
e.toggleClass('tinvwl-product-in-list', j).toggleClass('tinvwl-product-make-remove', j && g).attr('data-tinv-wl-action', j && g ? 'remove' : 'addto');
|
776 |
}
|
|
|
777 |
if (e.length && e.attr('data-tinv-wl-product-stats')) {
|
778 |
e.find('span.tinvwl-product-stats').remove();
|
779 |
var stats = JSON.parse(e.attr('data-tinv-wl-product-stats'));
|
|
|
780 |
for (var i in stats) {
|
781 |
if (-1 < i.indexOf(b.variation_id)) {
|
782 |
j = true;
|
785 |
}
|
786 |
}
|
787 |
}
|
|
|
788 |
a.preventDefault();
|
789 |
e.removeClass('disabled-add-wishlist');
|
790 |
+
});
|
791 |
|
792 |
+
// Refresh when storage changes in another tab
|
793 |
$(window).on('storage onstorage', function (e) {
|
794 |
if (hash_key === e.originalEvent.key && localStorage.getItem(hash_key) !== sessionStorage.getItem(hash_key)) {
|
795 |
if (localStorage.getItem(hash_key)) {
|
796 |
var data = JSON.parse(localStorage.getItem(hash_key));
|
|
|
797 |
if ('object' === _typeof(data) && null !== data && (data.hasOwnProperty('products') || data.hasOwnProperty('counter'))) {
|
798 |
set_hash(localStorage.getItem(hash_key));
|
799 |
}
|
800 |
}
|
801 |
}
|
802 |
+
});
|
803 |
|
804 |
+
// Get wishlist data from REST API.
|
805 |
var tinvwl_products = [],
|
806 |
+
tinvwl_counter = false;
|
807 |
$('a.tinvwl_add_to_wishlist_button').each(function () {
|
808 |
if ('undefined' !== $(this).data('tinv-wl-product') && $(this).data('tinv-wl-product')) {
|
809 |
tinvwl_products.push($(this).data('tinv-wl-product'));
|
812 |
$('.wishlist_products_counter_number').each(function () {
|
813 |
tinvwl_counter = true;
|
814 |
});
|
815 |
+
var get_data_ajax = function get_data_ajax() {
|
|
|
816 |
if (tinvwl_products.length || tinvwl_counter) {
|
817 |
+
var data = {
|
818 |
+
'tinvwl-action': 'get_data',
|
819 |
+
'tinvwl-security': tinvwl_add_to_wishlist.nonce
|
|
|
820 |
};
|
|
|
821 |
if (tinvwl_add_to_wishlist.wpml) {
|
822 |
+
data.lang = tinvwl_add_to_wishlist.wpml;
|
823 |
}
|
|
|
824 |
if (tinvwl_add_to_wishlist.wpml_default) {
|
825 |
+
data.lang_default = tinvwl_add_to_wishlist.wpml_default;
|
826 |
}
|
|
|
827 |
if ('1' == tinvwl_add_to_wishlist.stats) {
|
828 |
+
data.stats = tinvwl_add_to_wishlist.stats;
|
829 |
}
|
|
|
830 |
$.ajax({
|
831 |
+
url: tinvwl_add_to_wishlist.wc_ajax_url,
|
832 |
method: 'POST',
|
833 |
+
cache: false,
|
834 |
+
data: data,
|
835 |
beforeSend: function beforeSend(xhr) {
|
836 |
xhr.setRequestHeader('X-WP-Nonce', tinvwl_add_to_wishlist.nonce);
|
837 |
}
|
838 |
}).done(function (response) {
|
839 |
$('body').trigger('tinvwl_wishlist_ajax_response', [this, response]);
|
840 |
+
if (response.wishlists_data) {
|
841 |
+
set_hash(JSON.stringify(response.wishlists_data));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
842 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
843 |
});
|
844 |
}
|
845 |
};
|
|
|
846 |
$.fn.tinvwl_get_wishlist_data = function () {
|
847 |
if ($supports_html5_storage) {
|
848 |
if (tinvwl_add_to_wishlist.update_wishlists_data) {
|
849 |
localStorage.setItem(hash_key, '');
|
850 |
}
|
|
|
851 |
if (localStorage.getItem(hash_key)) {
|
852 |
var data = JSON.parse(localStorage.getItem(hash_key));
|
|
|
853 |
if ('object' === _typeof(data) && null !== data && (data.hasOwnProperty('products') || data.hasOwnProperty('counter'))) {
|
854 |
if (!data.hasOwnProperty('lang') && !tinvwl_add_to_wishlist.wpml || tinvwl_add_to_wishlist.wpml && data.lang === tinvwl_add_to_wishlist.wpml) {
|
855 |
mark_products(data);
|
858 |
}
|
859 |
}
|
860 |
}
|
|
|
861 |
if (tinvwl_add_to_wishlist.block_ajax_wishlists_data) {
|
862 |
return;
|
863 |
}
|
864 |
+
get_data_ajax();
|
|
|
865 |
};
|
|
|
866 |
$.fn.tinvwl_get_wishlist_data();
|
867 |
+
|
868 |
/* Dynamic buttons */
|
869 |
// Create an observer instance
|
|
|
870 |
var observer = new MutationObserver(function (mutations) {
|
871 |
tinvwl_products = [];
|
872 |
mutations.forEach(function (mutation) {
|
873 |
+
var newNodes = mutation.addedNodes;
|
874 |
|
875 |
+
// If there are new nodes added
|
876 |
if (null !== newNodes) {
|
877 |
var $nodes = $(newNodes);
|
878 |
$nodes.each(function () {
|
879 |
var $node = $(this),
|
880 |
+
els = $node.find('.tinvwl_add_to_wishlist_button');
|
|
|
881 |
if (els.length) {
|
882 |
els.each(function () {
|
883 |
if ('undefined' !== $(this).data('tinv-wl-product') && $(this).data('tinv-wl-product')) {
|
888 |
});
|
889 |
}
|
890 |
});
|
|
|
891 |
if (tinvwl_products.length) {
|
892 |
$.fn.tinvwl_get_wishlist_data();
|
893 |
}
|
894 |
+
});
|
895 |
|
896 |
+
// Configuration of the observer:
|
897 |
var config = {
|
898 |
childList: true,
|
899 |
subtree: true
|
901 |
var targetNode = document.body;
|
902 |
observer.observe(targetNode, config);
|
903 |
});
|
|
|
904 |
|
905 |
+
/* Storage Handling */
|
906 |
var $supports_html5_storage = true,
|
907 |
+
hash_key = tinvwl_add_to_wishlist.hash_key;
|
|
|
908 |
try {
|
909 |
$supports_html5_storage = 'sessionStorage' in window && null !== window.sessionStorage;
|
910 |
window.sessionStorage.setItem('ti', 'test');
|
914 |
} catch (err) {
|
915 |
$supports_html5_storage = false;
|
916 |
}
|
|
|
917 |
function mark_products(data) {
|
918 |
var g = '1' == window.tinvwl_add_to_wishlist['simple_flow'];
|
|
|
919 |
if (g || data.stats && '1' == tinvwl_add_to_wishlist.stats) {
|
920 |
$('a.tinvwl_add_to_wishlist_button').each(function () {
|
921 |
if (g) {
|
922 |
$(this).removeClass('tinvwl-product-make-remove').removeClass('tinvwl-product-already-on-wishlist').removeClass('tinvwl-product-in-list').attr('data-tinv-wl-action', 'addto').attr('data-tinv-wl-list', '[]');
|
923 |
}
|
|
|
924 |
if (data.stats) {
|
925 |
$(this).find('span.tinvwl-product-stats').remove();
|
926 |
}
|
927 |
});
|
928 |
}
|
|
|
929 |
$('body').trigger('tinvwl_wishlist_mark_products', [data]);
|
930 |
$.each(data.products, function (i, item) {
|
931 |
var id = i,
|
932 |
+
e = $('a.tinvwl_add_to_wishlist_button[data-tinv-wl-product="' + id + '"]');
|
933 |
e.each(function () {
|
934 |
var vid = parseInt($(this).attr('data-tinv-wl-productvariation')),
|
935 |
+
vids = $(this).data('tinv-wl-productvariations') || [],
|
936 |
+
j = false;
|
|
|
937 |
for (var i in item) {
|
938 |
if (item[i].hasOwnProperty('in') && Array.isArray(item[i].in) && (-1 < (item[i].in || []).indexOf(id) || -1 < (item[i].in || []).indexOf(vid) || vids.some(function (r) {
|
939 |
return 0 <= (item[i].in || []).indexOf(r);
|
941 |
j = true;
|
942 |
}
|
943 |
}
|
|
|
944 |
$('body').trigger('tinvwl_wishlist_product_marked', [this, j]);
|
945 |
$(this).attr('data-tinv-wl-list', JSON.stringify(item)).toggleClass('tinvwl-product-in-list', j).toggleClass('tinvwl-product-make-remove', j && g).attr('data-tinv-wl-action', j && g ? 'remove' : 'addto');
|
946 |
});
|
947 |
});
|
|
|
948 |
if (data.stats && '1' == tinvwl_add_to_wishlist.stats) {
|
949 |
$.each(data.stats, function (i, item) {
|
950 |
var id = i,
|
951 |
+
e = $('a.tinvwl_add_to_wishlist_button[data-tinv-wl-product="' + id + '"]');
|
952 |
e.each(function () {
|
953 |
$(this).attr('data-tinv-wl-product-stats', JSON.stringify(item));
|
954 |
var vid = parseInt($(this).attr('data-tinv-wl-productvariation')),
|
955 |
+
j = false;
|
|
|
956 |
for (var i in item) {
|
957 |
if (-1 < i.indexOf(vid)) {
|
958 |
j = true;
|
963 |
});
|
964 |
});
|
965 |
}
|
|
|
966 |
update_product_counter(data.counter);
|
967 |
}
|
|
|
|
|
968 |
|
969 |
+
/** Set the hash in both session and local storage */
|
970 |
function set_hash(hash) {
|
971 |
if ($supports_html5_storage) {
|
972 |
localStorage.setItem(hash_key, hash);
|
974 |
mark_products(JSON.parse(hash));
|
975 |
}
|
976 |
}
|
|
|
977 |
function update_product_counter(counter) {
|
978 |
if ('1' == window.tinvwl_add_to_wishlist['hide_zero_counter'] && 0 === counter) {
|
979 |
counter = 'false';
|
980 |
}
|
|
|
981 |
jQuery('i.wishlist-icon').addClass('added');
|
|
|
982 |
if ('false' !== counter) {
|
983 |
jQuery('.wishlist_products_counter_number, body.theme-woostify .wishlist-item-count').html(counter);
|
984 |
jQuery('i.wishlist-icon').attr('data-icon-label', counter);
|
986 |
jQuery('.wishlist_products_counter_number, body.theme-woostify .wishlist-item-count').html('').closest('span.wishlist-counter-with-products').removeClass('wishlist-counter-with-products');
|
987 |
jQuery('i.wishlist-icon').removeAttr('data-icon-label');
|
988 |
}
|
|
|
989 |
var has_products = !('0' == counter || 'false' == counter);
|
990 |
jQuery('.wishlist_products_counter').toggleClass('wishlist-counter-with-products', has_products);
|
991 |
setTimeout(function () {
|
992 |
jQuery('i.wishlist-icon').removeClass('added');
|
993 |
}, 500);
|
994 |
}
|
|
|
995 |
function FocusTrap(el) {
|
996 |
var inputs = $(el).find('select, input, textarea, button, a').filter(':visible');
|
997 |
var firstInput = inputs.first();
|
998 |
var lastInput = inputs.last();
|
|
|
999 |
|
1000 |
+
/*set focus on first input*/
|
1001 |
firstInput.focus().blur();
|
|
|
1002 |
|
1003 |
+
/*redirect last tab to first input*/
|
1004 |
lastInput.on('keydown', function (e) {
|
1005 |
if (9 === e.which && !e.shiftKey) {
|
1006 |
e.preventDefault();
|
1007 |
firstInput.focus();
|
1008 |
}
|
1009 |
});
|
|
|
1010 |
|
1011 |
+
/*redirect first shift+tab to last input*/
|
1012 |
firstInput.on('keydown', function (e) {
|
1013 |
if (9 === e.which && e.shiftKey) {
|
1014 |
e.preventDefault();
|
1029 |
});
|
1030 |
$('body').on('click', '.social-buttons .social:not(.social-email,.social-whatsapp,.social-clipboard)', function (e) {
|
1031 |
var newWind = window.open($(this).attr('href'), $(this).attr('title'), 'width=420,height=320,resizable=yes,scrollbars=yes,status=yes');
|
|
|
1032 |
if (newWind) {
|
1033 |
newWind.focus();
|
1034 |
e.preventDefault();
|
1035 |
}
|
1036 |
});
|
|
|
1037 |
if ('undefined' !== typeof ClipboardJS) {
|
1038 |
var clipboard = new ClipboardJS('.social-buttons .social.social-clipboard', {
|
1039 |
text: function text(trigger) {
|
1044 |
showTooltip(e.trigger, tinvwl_add_to_wishlist.tinvwl_clipboard);
|
1045 |
});
|
1046 |
var btns = document.querySelectorAll('.social-buttons .social.social-clipboard');
|
|
|
1047 |
for (var i = 0; i < btns.length; i++) {
|
1048 |
btns[i].addEventListener('mouseleave', clearTooltip);
|
1049 |
btns[i].addEventListener('blur', clearTooltip);
|
1050 |
}
|
1051 |
}
|
|
|
1052 |
$('body').on('click', '.social-buttons .social.social-clipboard', function (e) {
|
1053 |
e.preventDefault();
|
1054 |
});
|
1059 |
});
|
1060 |
$('body').on('click', '.tinv-wishlist .tinvwl-btn-onclick', function (e) {
|
1061 |
var url = $(this).data('url');
|
|
|
1062 |
if (url) {
|
1063 |
e.preventDefault();
|
1064 |
window.location = $(this).data('url');
|
1065 |
}
|
1066 |
});
|
1067 |
var navigationButton = $('.tinv-wishlist .navigation-button');
|
|
|
1068 |
if (navigationButton.length) {
|
1069 |
navigationButton.each(function () {
|
1070 |
var navigationButtons = $(this).find('> li');
|
|
|
1071 |
if (5 > navigationButtons.length) {
|
1072 |
navigationButtons.parent().addClass('tinvwl-btns-count-' + navigationButtons.length);
|
1073 |
}
|
1074 |
});
|
1075 |
}
|
|
|
1076 |
$('.tinv-login .showlogin').off('click').on('click', function (e) {
|
1077 |
e.preventDefault();
|
1078 |
$(this).closest('.tinv-login').find('.login').toggle();
|
1082 |
});
|
1083 |
});
|
1084 |
})(jQuery);
|
|
|
1085 |
function showTooltip(elem, msg) {
|
1086 |
elem.setAttribute('class', 'social social-clipboard tooltipped tooltipped-s');
|
1087 |
elem.setAttribute('aria-label', msg);
|
1088 |
}
|
|
|
1089 |
function clearTooltip(e) {
|
1090 |
e.currentTarget.setAttribute('class', 'social social-clipboard ');
|
1091 |
e.currentTarget.removeAttribute('aria-label');
|
1105 |
},
|
1106 |
rule: function rule() {
|
1107 |
var form_elements = $(this).parents('form').eq(0).find(s.selector),
|
1108 |
+
trigger = s.invert;
|
|
|
1109 |
if (0 === form_elements.length) {
|
1110 |
return s.ifempty;
|
1111 |
}
|
|
|
1112 |
form_elements.each(function () {
|
1113 |
if (trigger && !s.invert || !trigger && s.invert) {
|
1114 |
return;
|
1115 |
}
|
|
|
1116 |
trigger = Boolean(s.validate.call($(this)));
|
1117 |
});
|
1118 |
return trigger;
|
1122 |
return $(this).each(function () {
|
1123 |
$(this).on('click', function (event) {
|
1124 |
var ss = [];
|
|
|
1125 |
if ('undefined' !== typeof $(this).attr('tinvwl_break_submit')) {
|
1126 |
ss = $(this).attr('tinvwl_break_submit').split(',');
|
1127 |
}
|
|
|
1128 |
if (-1 !== jQuery.inArray(s.selector, ss)) {
|
1129 |
ss = [];
|
1130 |
}
|
|
|
1131 |
if (!s.rule.call($(this)) && 0 === ss.length) {
|
1132 |
alert(window.tinvwl_add_to_wishlist['tinvwl_break_submit']);
|
1133 |
event.preventDefault();
|
1134 |
}
|
|
|
1135 |
ss.push(s.selector);
|
1136 |
$(this).attr('tinvwl_break_submit', ss);
|
|
|
1137 |
if (s.rule.call($(this))) {
|
1138 |
$(this).removeAttr('tinvwl_break_submit');
|
1139 |
}
|
1140 |
});
|
1141 |
});
|
1142 |
};
|
|
|
1143 |
$(document).ready(function () {
|
1144 |
// Wishlist table bulk action checkbox
|
1145 |
$('body').on('click', '.global-cb', function () {
|
assets/js/public.min.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
/**
|
2 |
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
-
* @version 2.0.
|
4 |
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
*/
|
6 |
-
"use strict";function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function showTooltip(t,i){t.setAttribute("class","social social-clipboard tooltipped tooltipped-s"),t.setAttribute("aria-label",i)}function clearTooltip(t){t.currentTarget.setAttribute("class","social social-clipboard "),t.currentTarget.removeAttribute("aria-label")}!function(c){c.fn.tinvwl_to_wishlist=function(t){var i={api_url:window.location.href.split("?")[0],text_create:window.tinvwl_add_to_wishlist.text_create,text_already_in:window.tinvwl_add_to_wishlist.text_already_in,class:{dialogbox:".tinvwl_add_to_select_wishlist",select:".tinvwl_wishlist",newtitle:".tinvwl_new_input",dialogbutton:".tinvwl_button_add"},redirectTimer:null,onPrepareList:function(){},onGetDialogBox:function(){},onPrepareDialogBox:function(){c("body > .tinv-wishlist").length||c("body").append(c("<div>").addClass("tinv-wishlist")),c(this).appendTo("body > .tinv-wishlist")},onCreateWishList:function(t){c(this).append(c("<option>").html(t.title).val(t.ID).toggleClass("tinv_in_wishlist",t.in))},onSelectWishList:function(){},onDialogShow:function(t){c(t).addClass("tinv-modal-open"),c(t).removeClass("ftinvwl-pulse")},onDialogHide:function(t){c(t).removeClass("tinv-modal-open"),c(t).removeClass("ftinvwl-pulse")},onInited:function(){},onClick:function(){if(c(this).is(".disabled-add-wishlist"))return!1;c(this).is(".ftinvwl-animated")&&c(this).addClass("ftinvwl-pulse"),(this.tinvwl_dialog?this.tinvwl_dialog.show_list:o.onActionProduct).call(this)},onPrepareDataAction:function(t,i){c("body").trigger("tinvwl_wishlist_button_clicked",[t,i])},filterProductAlreadyIn:function(t){var t=t||[],e={};return c("form.cart[method=post], .woocommerce-variation-add-to-cart, form.vtajaxform[method=post]").find("input, select").each(function(){var t=c(this).attr("name"),i=c(this).attr("type"),n=c(this).val();("checkbox"!==i&&"radio"!==i||c(this).is(":checked"))&&(e["form"+t]=n)}),e=e.formvariation_id,t.filter(function(t){var i;return"object"===_typeof(t.in)&&"string"==typeof e?(i=parseInt(e),0<=t.in.indexOf(i)):t.in})},onMultiProductAlreadyIn:function(t){var t=t||[],n=(t=o.onPrepareList.call(t)||t,t=o.filterProductAlreadyIn.call(this,t)||t,c(this).parent().parent().find(".already-in").remove(),"");0===t.length||(n=c("<ul>"),c.each(t,function(t,i){n.append(c("<li>").html(c("<a>").html(i.title).attr({href:i.url})).val(i.ID))})),n.length&&c(this).closest(".tinv-modal-inner").find("img").after(c("<div>").addClass("already-in").html(o.text_already_in+" ").append(n))},onAction:{redirect:function(t){o.redirectTimer&&clearTimeout(o.redirectTimer),o.redirectTimer=window.setTimeout(function(){window.location.href=t},4e3)},force_redirect:function(t){window.location.href=t},wishlists:function(t){},msg:function(t){if(!t)return!1;var i=c(t).eq(0);c("body > .tinv-wishlist").length||c("body").append(c("<div>").addClass("tinv-wishlist")),c("body > .tinv-wishlist").append(i),d("body > .tinv-wishlist"),o.redirectTimer||(o.removeTimer=window.setTimeout(function(){i.remove(),o.redirectTimer&&clearTimeout(o.redirectTimer)},tinvwl_add_to_wishlist.popup_timer)),i.on("click",".tinv-close-modal, .tinvwl_button_close, .tinv-overlay",function(t){t.preventDefault(),i.remove(),o.redirectTimer&&clearTimeout(o.redirectTimer),o.removeTimer&&clearTimeout(o.removeTimer)})},status:function(t){c("body").trigger("tinvwl_wishlist_added_status",[this,t])},removed:function(t){},make_remove:function(t){},wishlists_data:function(t){r(JSON.stringify(t))}}},o=(i.onActionProduct=function(t,i){var r={form:{},tinv_wishlist_id:t||"",tinv_wishlist_name:i||"",product_type:c(this).attr("data-tinv-wl-producttype"),product_id:c(this).attr("data-tinv-wl-product")||0,product_variation:c(this).attr("data-tinv-wl-productvariation")||0,product_action:c(this).attr("data-tinv-wl-action")||"addto",redirect:window.location.href},n=this,e=[],d=new FormData;tinvwl_add_to_wishlist.wpml&&(r.lang=tinvwl_add_to_wishlist.wpml),tinvwl_add_to_wishlist.wpml_default&&(r.lang_default=tinvwl_add_to_wishlist.wpml_default),"1"==tinvwl_add_to_wishlist.stats&&(r.stats=tinvwl_add_to_wishlist.stats),c('form.cart[method=post][data-product_id="'+c(this).attr("data-tinv-wl-product")+'"], form.vtajaxform[method=post][data-product_id="'+c(this).attr("data-tinv-wl-product")+'"]').each(function(){e.push(c(this))}),e.length||(c(n).closest("form.cart[method=post], form.vtajaxform[method=post]").each(function(){e.push(c(this))}),e.length||e.push(c("form.cart[method=post]"))),c('.tinv-wraper[data-tinvwl_product_id="'+c(this).attr("data-tinv-wl-product")+'"]').each(function(){e.push(c(this))}),c.each(e,function(t,i){c(i).find("input:not(:disabled), select:not(:disabled), textarea:not(:disabled)").each(function(){function o(t,i){if("object"!==_typeof(i))return i;for(var n in void 0===t&&(t={}),i)if(""===n){var e=-1;for(e in t);t[e=parseInt(e)+1]=o(t[n],i[n])}else t[n]=o(t[n],i[n]);return t}var t,i=c(this).attr("name"),n=c(this).attr("type"),e=c(this).val(),a=10;if("button"!==n&&void 0!==i){for(;/^(.+)\[([^\[\]]*?)\]$/.test(i)&&0<a;){var s,l=i.match(/^(.+)\[([^\[\]]*?)\]$/);3===l.length&&((s={})[l[2]]=e,e=s),i=l[1],a--}"file"!==n||(t=c(this)[0].files)&&d.append(i,t[0]),"checkbox"===n||"radio"===n?c(this).is(":checked")&&(e.length||"object"===_typeof(e)||(e=!0),r.form[i]=o(r.form[i],e)):r.form[i]=o(r.form[i],e)}})}),r=o.onPrepareDataAction.call(n,n,r)||r,c.each(r,function(n,t){"form"===n?c.each(t,function(t,i){"object"===_typeof(i)&&(i=JSON.stringify(i)),d.append(n+"["+t+"]",i)}):d.append(n,t)}),c.ajax({url:o.api_url,method:"POST",contentType:!1,processData:!1,data:d}).done(function(t){if(c("body").trigger("tinvwl_wishlist_ajax_response",[this,t]),o.onDialogHide.call(n.tinvwl_dialog,n),"object"===_typeof(t))for(var i in t)"function"==typeof o.onAction[i]&&o.onAction[i].call(n,t[i]);else"function"==typeof o.onAction.msg&&o.onAction.msg.call(n,t)})},c.extend(!0,{},i,t));return c(this).each(function(){if(!c(this).attr("data-tinv-wl-list"))return!1;var t,e;o.dialogbox&&o.dialogbox.length&&(this.tinvwl_dialog=o.dialogbox),this.tinvwl_dialog||(this.tinvwl_dialog=o.onGetDialogBox.call(this)),this.tinvwl_dialog||(t=c(this).nextAll(o.class.dialogbox).eq(0)).length&&(this.tinvwl_dialog=t),this.tinvwl_dialog&&(o.onPrepareDialogBox.call(this.tinvwl_dialog),"function"!=typeof this.tinvwl_dialog.update_list&&(this.tinvwl_dialog.update_list=function(t){var n=c(this).find(o.class.select).eq(0);c(this).find(o.class.newtitle).hide().val(""),n.html(""),c.each(t,function(t,i){o.onCreateWishList.call(n,i)}),o.text_create&&o.onCreateWishList.call(n,{ID:"",title:o.text_create,in:!1}),o.onMultiProductAlreadyIn.call(n,t),o.onSelectWishList.call(n,t),c(this).find(o.class.newtitle).toggle(""===n.val())}),"function"!=typeof this.tinvwl_dialog.show_list&&(this.tinvwl_dialog.show_list=function(){var t=JSON.parse(c(this).attr("data-tinv-wl-list"))||[];t.length?(t=o.onPrepareList.call(t)||t,this.tinvwl_dialog.update_list(t),o.onDialogShow.call(this.tinvwl_dialog,this)):o.onActionProduct.call(this)}),c((e=this).tinvwl_dialog).find(o.class.dialogbutton).off("click").on("click",function(){var t,i=c(e.tinvwl_dialog).find(o.class.select),n=c(e.tinvwl_dialog).find(o.class.newtitle);i.val()||n.val()?o.onActionProduct.call(e,i.val(),n.val()):((t=n.is(":visible")?n:i).addClass("empty-name-wishlist"),window.setTimeout(function(){t.removeClass("empty-name-wishlist")},1e3))})),c(this).off("click").on("click",o.onClick),o.onInited.call(this,o)})},c(document).ready(function(){c("body").on("click keydown",".tinvwl_add_to_wishlist_button",function(t){if("keydown"===t.type){var i=void 0!==t.key?t.key:t.keyCode;if(!("Enter"===i||13===i||0<=["Spacebar"," "].indexOf(i)||32===i))return;t.preventDefault()}if(c("body").trigger("tinvwl_add_to_wishlist_button_click",[this]),c(this).is(".disabled-add-wishlist"))return t.preventDefault(),void window.alert(tinvwl_add_to_wishlist.i18n_make_a_selection_text);c(this).is(".inited-add-wishlist")||c(this).tinvwl_to_wishlist({onInited:function(t){c(this).addClass("inited-add-wishlist"),t.onClick.call(this)}})}),c("body").on("click keydown",'button[name="tinvwl-remove"]',function(t){if("keydown"===t.type){var i=void 0!==t.key?t.key:t.keyCode;if(!("Enter"===i||13===i||0<=["Spacebar"," "].indexOf(i)||32===i))return}t.preventDefault();var e=c(this);e.is(".inited-wishlist-action")||(e.addClass("inited-wishlist-action"),i={"tinvwl-product_id":e.val(),"tinvwl-action":"remove","tinvwl-security":tinvwl_add_to_wishlist.nonce,"tinvwl-paged":e.closest("form").data("tinvwl_paged"),"tinvwl-sharekey":e.closest("form").data("tinvwl_sharekey")},c.ajax({url:tinvwl_add_to_wishlist.wc_ajax_url,method:"POST",cache:!1,data:i,beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",tinvwl_add_to_wishlist.nonce)}}).done(function(t){var i,n;c("body").trigger("tinvwl_wishlist_ajax_response",[this,t]),e.removeClass("inited-wishlist-action"),t.msg&&(i=c(t.msg).eq(0),c("body > .tinv-wishlist").length||c("body").append(c("<div>").addClass("tinv-wishlist")),c("body > .tinv-wishlist").append(i),d("body > .tinv-wishlist"),i.on("click",".tinv-close-modal, .tinvwl_button_close, .tinv-overlay",function(t){t.preventDefault(),i.remove()}),n=n||window.setTimeout(function(){i.remove(),n&&clearTimeout(n)},tinvwl_add_to_wishlist.popup_timer)),t.status&&(c("div.tinv-wishlist.woocommerce.tinv-wishlist-clear").replaceWith(t.content),c(".tinvwl-break-input").tinvwl_break_submit({selector:".tinvwl-break-input-filed"}),c(".tinvwl-break-checkbox").tinvwl_break_submit({selector:"table td input[type=checkbox]",validate:function(){return c(this).is(":checked")}}),jQuery.fn.tinvwl_get_wishlist_data()),t.wishlists_data&&r(JSON.stringify(t.wishlists_data))}))}),c("body").on("click keydown",'button[name="tinvwl-add-to-cart"]',function(t){if("keydown"===t.type){var i=void 0!==t.key?t.key:t.keyCode;if(!("Enter"===i||13===i||0<=["Spacebar"," "].indexOf(i)||32===i))return}t.preventDefault();var e=c(this);e.is(".inited-wishlist-action")||(e.addClass("inited-wishlist-action"),i={"tinvwl-product_id":e.val(),"tinvwl-action":"add_to_cart_single","tinvwl-security":tinvwl_add_to_wishlist.nonce,"tinvwl-paged":e.closest("form").data("tinvwl_paged"),"tinvwl-sharekey":e.closest("form").data("tinvwl_sharekey")},c.ajax({url:tinvwl_add_to_wishlist.wc_ajax_url,method:"POST",cache:!1,data:i,beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",tinvwl_add_to_wishlist.nonce)}}).done(function(t){var i,n;c("body").trigger("tinvwl_wishlist_ajax_response",[this,t]),e.removeClass("inited-wishlist-action"),t.redirect&&(window.location.href=t.redirect),t.msg&&(i=c(t.msg).eq(0),c("body > .tinv-wishlist").length||c("body").append(c("<div>").addClass("tinv-wishlist")),c("body > .tinv-wishlist").append(i),d("body > .tinv-wishlist"),i.on("click",".tinv-close-modal, .tinvwl_button_close, .tinv-overlay",function(t){t.preventDefault(),i.remove()}),n=n||window.setTimeout(function(){i.remove(),n&&clearTimeout(n)},tinvwl_add_to_wishlist.popup_timer)),t.redirect||(c(document.body).trigger("wc_fragment_refresh"),c("div.tinv-wishlist.woocommerce.tinv-wishlist-clear").replaceWith(t.content),jQuery.fn.tinvwl_get_wishlist_data(),t.wishlists_data&&r(JSON.stringify(t.wishlists_data)))}))}),c("body").on("click keydown",'button[name="tinvwl-action-product_all"]',function(t){if("keydown"===t.type){var i=void 0!==t.key?t.key:t.keyCode;if(!("Enter"===i||13===i||0<=["Spacebar"," "].indexOf(i)||32===i))return}t.preventDefault();var e=c(this);e.is(".inited-wishlist-action")||(e.addClass("inited-wishlist-action"),i={"tinvwl-action":"add_to_cart_all","tinvwl-security":tinvwl_add_to_wishlist.nonce,"tinvwl-paged":e.closest("form").data("tinvwl_paged"),"tinvwl-sharekey":e.closest("form").data("tinvwl_sharekey")},c.ajax({url:tinvwl_add_to_wishlist.wc_ajax_url,method:"POST",cache:!1,data:i,beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",tinvwl_add_to_wishlist.nonce)}}).done(function(t){var i,n;c("body").trigger("tinvwl_wishlist_ajax_response",[this,t]),e.removeClass("inited-wishlist-action"),t.redirect&&(window.location.href=t.redirect),t.msg&&(i=c(t.msg).eq(0),c("body > .tinv-wishlist").length||c("body").append(c("<div>").addClass("tinv-wishlist")),c("body > .tinv-wishlist").append(i),d("body > .tinv-wishlist"),i.on("click",".tinv-close-modal, .tinvwl_button_close, .tinv-overlay",function(t){t.preventDefault(),i.remove()}),n=n||window.setTimeout(function(){i.remove(),n&&clearTimeout(n)},tinvwl_add_to_wishlist.popup_timer)),t.redirect||(c(document.body).trigger("wc_fragment_refresh"),c("div.tinv-wishlist.woocommerce.tinv-wishlist-clear").replaceWith(t.content),jQuery.fn.tinvwl_get_wishlist_data(),t.wishlists_data&&r(JSON.stringify(t.wishlists_data)))}))}),c("body").on("click keydown",'button[name="tinvwl-action-product_apply"], button[name="tinvwl-action-product_selected"]',function(t){if("keydown"===t.type){var i=void 0!==t.key?t.key:t.keyCode;if(!("Enter"===i||13===i||0<=["Spacebar"," "].indexOf(i)||32===i))return}t.preventDefault();var e,n=[],o=(c('input[name="wishlist_pr[]"]:checked').each(function(){n.push(this.value)}),c(this));n.length&&("tinvwl-action-product_selected"===o.attr("name")||c("select#tinvwl_product_actions option").filter(":selected").val())?o.is(".inited-wishlist-action")||(o.addClass("inited-wishlist-action"),e="",e="tinvwl-action-product_selected"===o.attr("name")?"add_to_cart_selected":c("select#tinvwl_product_actions option").filter(":selected").val(),i={"tinvwl-products":n,"tinvwl-action":e,"tinvwl-security":tinvwl_add_to_wishlist.nonce,"tinvwl-paged":o.closest("form").data("tinvwl_paged"),"tinvwl-sharekey":o.closest("form").data("tinvwl_sharekey")},c.ajax({url:tinvwl_add_to_wishlist.wc_ajax_url,method:"POST",cache:!1,data:i,beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",tinvwl_add_to_wishlist.nonce)}}).done(function(t){var i,n;c("body").trigger("tinvwl_wishlist_ajax_response",[this,t]),o.removeClass("inited-wishlist-action"),t.redirect&&(window.location.href=t.redirect),t.msg&&(i=c(t.msg).eq(0),c("body > .tinv-wishlist").length||c("body").append(c("<div>").addClass("tinv-wishlist")),c("body > .tinv-wishlist").append(i),d("body > .tinv-wishlist"),i.on("click",".tinv-close-modal, .tinvwl_button_close, .tinv-overlay",function(t){t.preventDefault(),i.remove()}),n=n||window.setTimeout(function(){i.remove(),n&&clearTimeout(n)},tinvwl_add_to_wishlist.popup_timer)),t.redirect||("add_to_cart_selected"===e&&c(document.body).trigger("wc_fragment_refresh"),c("div.tinv-wishlist.woocommerce.tinv-wishlist-clear").replaceWith(t.content),jQuery.fn.tinvwl_get_wishlist_data(),t.wishlists_data&&r(JSON.stringify(t.wishlists_data)))})):alert(window.tinvwl_add_to_wishlist.tinvwl_break_submit)}),c(document).on("hide_variation",".variations_form",function(t){var i=c('.tinvwl_add_to_wishlist_button:not(.tinvwl-loop)[data-tinv-wl-product="'+c(this).data("product_id")+'"]');if(i.attr("data-tinv-wl-productvariation",0),i.length&&i.attr("data-tinv-wl-list")){var n=JSON.parse(i.attr("data-tinv-wl-list")),e=!1,o="1"==window.tinvwl_add_to_wishlist.simple_flow;for(a in n)n[a].hasOwnProperty("in")&&Array.isArray(n[a].in)&&-1<(n[a].in||[]).indexOf(0)&&(e=!0);i.toggleClass("tinvwl-product-in-list",e).toggleClass("tinvwl-product-make-remove",e&&o).attr("data-tinv-wl-action",e&&o?"remove":"addto")}if(i.length&&i.attr("data-tinv-wl-product-stats")){i.find("span.tinvwl-product-stats").remove();var a,s=JSON.parse(i.attr("data-tinv-wl-product-stats"));for(a in s)-1<a.indexOf(0)&&(e=!0,c("body").trigger("tinvwl_wishlist_product_stats",[i,e]),i.append('<span class="tinvwl-product-stats">'+s[a]+"</span>"))}i.length&&!tinvwl_add_to_wishlist.allow_parent_variable&&(t.preventDefault(),i.addClass("disabled-add-wishlist"))}),c(document).on("show_variation",".variations_form",function(t,i,n){var e=c('.tinvwl_add_to_wishlist_button:not(.tinvwl-loop)[data-tinv-wl-product="'+c(this).data("product_id")+'"]');if(e.attr("data-tinv-wl-productvariation",i.variation_id),e.length&&e.attr("data-tinv-wl-list")){var o=JSON.parse(e.attr("data-tinv-wl-list")),a=!1,s="1"==window.tinvwl_add_to_wishlist.simple_flow;for(l in o)o[l].hasOwnProperty("in")&&Array.isArray(o[l].in)&&-1<(o[l].in||[]).indexOf(i.variation_id)&&(a=!0);e.toggleClass("tinvwl-product-in-list",a).toggleClass("tinvwl-product-make-remove",a&&s).attr("data-tinv-wl-action",a&&s?"remove":"addto")}if(e.length&&e.attr("data-tinv-wl-product-stats")){e.find("span.tinvwl-product-stats").remove();var l,r=JSON.parse(e.attr("data-tinv-wl-product-stats"));for(l in r)-1<l.indexOf(i.variation_id)&&(a=!0,c("body").trigger("tinvwl_wishlist_product_stats",[e,a]),e.append('<span class="tinvwl-product-stats">'+r[l]+"</span>"))}t.preventDefault(),e.removeClass("disabled-add-wishlist")}),c(window).on("storage onstorage",function(t){s===t.originalEvent.key&&localStorage.getItem(s)!==sessionStorage.getItem(s)&&(!localStorage.getItem(s)||"object"===_typeof(t=JSON.parse(localStorage.getItem(s)))&&null!==t&&(t.hasOwnProperty("products")||t.hasOwnProperty("counter"))&&r(localStorage.getItem(s)))});function i(){var t;(n.length||e)&&(t={},tinvwl_add_to_wishlist.wpml&&(t.lang=tinvwl_add_to_wishlist.wpml),tinvwl_add_to_wishlist.wpml_default&&(t.lang_default=tinvwl_add_to_wishlist.wpml_default),"1"==tinvwl_add_to_wishlist.stats&&(t.stats=tinvwl_add_to_wishlist.stats),c.ajax({url:tinvwl_add_to_wishlist.plugin_url+"includes/api/ajax.php",method:"POST",data:t,beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",tinvwl_add_to_wishlist.nonce)}}).done(function(t){c("body").trigger("tinvwl_wishlist_ajax_response",[this,t]),r(JSON.stringify(t)),l(t)}).fail(function(){var t;(n.length||e)&&(t={ids:n,counter:e,tinvwl_request:!0},tinvwl_add_to_wishlist.wpml&&(t.lang=tinvwl_add_to_wishlist.wpml),tinvwl_add_to_wishlist.wpml_default&&(t.lang_default=tinvwl_add_to_wishlist.wpml_default),"1"==tinvwl_add_to_wishlist.stats&&(t.stats=tinvwl_add_to_wishlist.stats),c.ajax({url:tinvwl_add_to_wishlist.rest_root+"wishlist/v1/products",method:"POST",data:t,beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",tinvwl_add_to_wishlist.nonce)}}).done(function(t){c("body").trigger("tinvwl_wishlist_ajax_response",[this,t]),r(JSON.stringify(t)),l(t)}))}))}var n=[],e=!1,t=(c("a.tinvwl_add_to_wishlist_button").each(function(){"undefined"!==c(this).data("tinv-wl-product")&&c(this).data("tinv-wl-product")&&n.push(c(this).data("tinv-wl-product"))}),c(".wishlist_products_counter_number").each(function(){e=!0}),c.fn.tinvwl_get_wishlist_data=function(){if(a&&(tinvwl_add_to_wishlist.update_wishlists_data&&localStorage.setItem(s,""),localStorage.getItem(s))){var t=JSON.parse(localStorage.getItem(s));if("object"===_typeof(t)&&null!==t&&(t.hasOwnProperty("products")||t.hasOwnProperty("counter"))&&(!t.hasOwnProperty("lang")&&!tinvwl_add_to_wishlist.wpml||tinvwl_add_to_wishlist.wpml&&t.lang===tinvwl_add_to_wishlist.wpml))return void l(t)}tinvwl_add_to_wishlist.block_ajax_wishlists_data||i()},c.fn.tinvwl_get_wishlist_data(),new MutationObserver(function(t){n=[],t.forEach(function(t){t=t.addedNodes;null!==t&&c(t).each(function(){var t=c(this).find(".tinvwl_add_to_wishlist_button");t.length&&t.each(function(){"undefined"!==c(this).data("tinv-wl-product")&&c(this).data("tinv-wl-product")&&n.push(c(this).data("tinv-wl-product"))})})}),n.length&&c.fn.tinvwl_get_wishlist_data()})),o=document.body;t.observe(o,{childList:!0,subtree:!0})});var a=!0,s=tinvwl_add_to_wishlist.hash_key;try{a="sessionStorage"in window&&null!==window.sessionStorage,window.sessionStorage.setItem("ti","test"),window.sessionStorage.removeItem("ti"),window.localStorage.setItem("ti","test"),window.localStorage.removeItem("ti")}catch(t){a=!1}function l(t){var s="1"==window.tinvwl_add_to_wishlist.simple_flow,i=((s||t.stats&&"1"==tinvwl_add_to_wishlist.stats)&&c("a.tinvwl_add_to_wishlist_button").each(function(){s&&c(this).removeClass("tinvwl-product-make-remove").removeClass("tinvwl-product-already-on-wishlist").removeClass("tinvwl-product-in-list").attr("data-tinv-wl-action","addto").attr("data-tinv-wl-list","[]"),t.stats&&c(this).find("span.tinvwl-product-stats").remove()}),c("body").trigger("tinvwl_wishlist_mark_products",[t]),c.each(t.products,function(t,o){var a=t;c('a.tinvwl_add_to_wishlist_button[data-tinv-wl-product="'+a+'"]').each(function(){var i,t=parseInt(c(this).attr("data-tinv-wl-productvariation")),n=c(this).data("tinv-wl-productvariations")||[],e=!1;for(i in o)o[i].hasOwnProperty("in")&&Array.isArray(o[i].in)&&(-1<(o[i].in||[]).indexOf(a)||-1<(o[i].in||[]).indexOf(t)||n.some(function(t){return 0<=(o[i].in||[]).indexOf(t)}))&&(e=!0);c("body").trigger("tinvwl_wishlist_product_marked",[this,e]),c(this).attr("data-tinv-wl-list",JSON.stringify(o)).toggleClass("tinvwl-product-in-list",e).toggleClass("tinvwl-product-make-remove",e&&s).attr("data-tinv-wl-action",e&&s?"remove":"addto")})}),t.stats&&"1"==tinvwl_add_to_wishlist.stats&&c.each(t.stats,function(t,n){c('a.tinvwl_add_to_wishlist_button[data-tinv-wl-product="'+t+'"]').each(function(){c(this).attr("data-tinv-wl-product-stats",JSON.stringify(n));var t,i=parseInt(c(this).attr("data-tinv-wl-productvariation"));for(t in n)-1<t.indexOf(i)&&(c("body").trigger("tinvwl_wishlist_product_stats",[this,!0]),c(this).append('<span class="tinvwl-product-stats">'+n[t]+"</span>"))})}),t.counter);"1"==window.tinvwl_add_to_wishlist.hide_zero_counter&&0===i&&(i="false"),jQuery("i.wishlist-icon").addClass("added"),"false"!==i?(jQuery(".wishlist_products_counter_number, body.theme-woostify .wishlist-item-count").html(i),jQuery("i.wishlist-icon").attr("data-icon-label",i)):(jQuery(".wishlist_products_counter_number, body.theme-woostify .wishlist-item-count").html("").closest("span.wishlist-counter-with-products").removeClass("wishlist-counter-with-products"),jQuery("i.wishlist-icon").removeAttr("data-icon-label")),i=!("0"==i||"false"==i),jQuery(".wishlist_products_counter").toggleClass("wishlist-counter-with-products",i),setTimeout(function(){jQuery("i.wishlist-icon").removeClass("added")},500)}function r(t){a&&(localStorage.setItem(s,t),sessionStorage.setItem(s,t),l(JSON.parse(t)))}function d(t){var t=c(t).find("select, input, textarea, button, a").filter(":visible"),i=t.first(),n=t.last();i.focus().blur(),n.on("keydown",function(t){9!==t.which||t.shiftKey||(t.preventDefault(),i.focus())}),i.on("keydown",function(t){9===t.which&&t.shiftKey&&(t.preventDefault(),n.focus())})}}(jQuery),function(e){e(document).ready(function(){if(e(".tinv-lists-nav").each(function(){e(this).html().trim().length||e(this).remove()}),e("body").on("click",".social-buttons .social:not(.social-email,.social-whatsapp,.social-clipboard)",function(t){var i=window.open(e(this).attr("href"),e(this).attr("title"),"width=420,height=320,resizable=yes,scrollbars=yes,status=yes");i&&(i.focus(),t.preventDefault())}),"undefined"!=typeof ClipboardJS){new ClipboardJS(".social-buttons .social.social-clipboard",{text:function(t){return t.getAttribute("href")}}).on("success",function(t){showTooltip(t.trigger,tinvwl_add_to_wishlist.tinvwl_clipboard)});for(var t=document.querySelectorAll(".social-buttons .social.social-clipboard"),i=0;i<t.length;i++)t[i].addEventListener("mouseleave",clearTooltip),t[i].addEventListener("blur",clearTooltip)}e("body").on("click",".social-buttons .social.social-clipboard",function(t){t.preventDefault()}),e("body").on("click",".tinv-wishlist .tinv-overlay, .tinv-wishlist .tinv-close-modal, .tinv-wishlist .tinvwl_button_close",function(t){t.preventDefault(),e(this).parents(".tinv-modal:first").removeClass("tinv-modal-open"),e("body").trigger("tinvwl_modal_closed",[this])}),e("body").on("click",".tinv-wishlist .tinvwl-btn-onclick",function(t){e(this).data("url")&&(t.preventDefault(),window.location=e(this).data("url"))});var n=e(".tinv-wishlist .navigation-button");n.length&&n.each(function(){var t=e(this).find("> li");t.length<5&&t.parent().addClass("tinvwl-btns-count-"+t.length)}),e(".tinv-login .showlogin").off("click").on("click",function(t){t.preventDefault(),e(this).closest(".tinv-login").find(".login").toggle()}),e(".tinv-wishlist table.tinvwl-table-manage-list tfoot td").each(function(){e(this).toggle(!!e(this).children().not(".look_in").length||!!e(this).children(".look_in").children().length)})})}(jQuery),function(e){e.fn.tinvwl_break_submit=function(t){var n=e.extend(!0,{},{selector:"input, select, textarea",ifempty:!0,invert:!1,validate:function(){return e(this).val()},rule:function(){var t=e(this).parents("form").eq(0).find(n.selector),i=n.invert;return 0===t.length?n.ifempty:(t.each(function(){i&&!n.invert||!i&&n.invert||(i=Boolean(n.validate.call(e(this))))}),i)}},t);return e(this).each(function(){e(this).on("click",function(t){var i=[];void 0!==e(this).attr("tinvwl_break_submit")&&(i=e(this).attr("tinvwl_break_submit").split(",")),-1!==jQuery.inArray(n.selector,i)&&(i=[]),n.rule.call(e(this))||0!==i.length||(alert(window.tinvwl_add_to_wishlist.tinvwl_break_submit),t.preventDefault()),i.push(n.selector),e(this).attr("tinvwl_break_submit",i),n.rule.call(e(this))&&e(this).removeAttr("tinvwl_break_submit")})})},e(document).ready(function(){e("body").on("click",".global-cb",function(){e(this).closest("table").eq(0).find(".product-cb input[type=checkbox], .wishlist-cb input[type=checkbox]").prop("checked",e(this).is(":checked"))})})}(jQuery);
|
1 |
/**
|
2 |
* TI WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
|
3 |
+
* @version 2.0.7
|
4 |
* @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
5 |
*/
|
6 |
+
"use strict";function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function showTooltip(t,i){t.setAttribute("class","social social-clipboard tooltipped tooltipped-s"),t.setAttribute("aria-label",i)}function clearTooltip(t){t.currentTarget.setAttribute("class","social social-clipboard "),t.currentTarget.removeAttribute("aria-label")}!function(c){c.fn.tinvwl_to_wishlist=function(t){var i={api_url:window.location.href.split("?")[0],text_create:window.tinvwl_add_to_wishlist.text_create,text_already_in:window.tinvwl_add_to_wishlist.text_already_in,class:{dialogbox:".tinvwl_add_to_select_wishlist",select:".tinvwl_wishlist",newtitle:".tinvwl_new_input",dialogbutton:".tinvwl_button_add"},redirectTimer:null,onPrepareList:function(){},onGetDialogBox:function(){},onPrepareDialogBox:function(){c("body > .tinv-wishlist").length||c("body").append(c("<div>").addClass("tinv-wishlist")),c(this).appendTo("body > .tinv-wishlist")},onCreateWishList:function(t){c(this).append(c("<option>").html(t.title).val(t.ID).toggleClass("tinv_in_wishlist",t.in))},onSelectWishList:function(){},onDialogShow:function(t){c(t).addClass("tinv-modal-open"),c(t).removeClass("ftinvwl-pulse")},onDialogHide:function(t){c(t).removeClass("tinv-modal-open"),c(t).removeClass("ftinvwl-pulse")},onInited:function(){},onClick:function(){if(c(this).is(".disabled-add-wishlist"))return!1;c(this).is(".ftinvwl-animated")&&c(this).addClass("ftinvwl-pulse"),(this.tinvwl_dialog?this.tinvwl_dialog.show_list:o.onActionProduct).call(this)},onPrepareDataAction:function(t,i){c("body").trigger("tinvwl_wishlist_button_clicked",[t,i])},filterProductAlreadyIn:function(t){var t=t||[],e={};return c("form.cart[method=post], .woocommerce-variation-add-to-cart, form.vtajaxform[method=post]").find("input, select").each(function(){var t=c(this).attr("name"),i=c(this).attr("type"),n=c(this).val();("checkbox"!==i&&"radio"!==i||c(this).is(":checked"))&&(e["form"+t]=n)}),e=e.formvariation_id,t.filter(function(t){var i;return"object"===_typeof(t.in)&&"string"==typeof e?(i=parseInt(e),0<=t.in.indexOf(i)):t.in})},onMultiProductAlreadyIn:function(t){var t=t||[],n=(t=o.onPrepareList.call(t)||t,t=o.filterProductAlreadyIn.call(this,t)||t,c(this).parent().parent().find(".already-in").remove(),"");0===t.length||(n=c("<ul>"),c.each(t,function(t,i){n.append(c("<li>").html(c("<a>").html(i.title).attr({href:i.url})).val(i.ID))})),n.length&&c(this).closest(".tinv-modal-inner").find("img").after(c("<div>").addClass("already-in").html(o.text_already_in+" ").append(n))},onAction:{redirect:function(t){o.redirectTimer&&clearTimeout(o.redirectTimer),o.redirectTimer=window.setTimeout(function(){window.location.href=t},4e3)},force_redirect:function(t){window.location.href=t},wishlists:function(t){},msg:function(t){if(!t)return!1;var i=c(t).eq(0);c("body > .tinv-wishlist").length||c("body").append(c("<div>").addClass("tinv-wishlist")),c("body > .tinv-wishlist").append(i),d("body > .tinv-wishlist"),o.redirectTimer||(o.removeTimer=window.setTimeout(function(){i.remove(),o.redirectTimer&&clearTimeout(o.redirectTimer)},tinvwl_add_to_wishlist.popup_timer)),i.on("click",".tinv-close-modal, .tinvwl_button_close, .tinv-overlay",function(t){t.preventDefault(),i.remove(),o.redirectTimer&&clearTimeout(o.redirectTimer),o.removeTimer&&clearTimeout(o.removeTimer)})},status:function(t){c("body").trigger("tinvwl_wishlist_added_status",[this,t])},removed:function(t){},make_remove:function(t){},wishlists_data:function(t){l(JSON.stringify(t))}}},o=(i.onActionProduct=function(t,i){var d={form:{},tinv_wishlist_id:t||"",tinv_wishlist_name:i||"",product_type:c(this).attr("data-tinv-wl-producttype"),product_id:c(this).attr("data-tinv-wl-product")||0,product_variation:c(this).attr("data-tinv-wl-productvariation")||0,product_action:c(this).attr("data-tinv-wl-action")||"addto",redirect:window.location.href},n=this,e=[],r=new FormData;tinvwl_add_to_wishlist.wpml&&(d.lang=tinvwl_add_to_wishlist.wpml),tinvwl_add_to_wishlist.wpml_default&&(d.lang_default=tinvwl_add_to_wishlist.wpml_default),"1"==tinvwl_add_to_wishlist.stats&&(d.stats=tinvwl_add_to_wishlist.stats),c('form.cart[method=post][data-product_id="'+c(this).attr("data-tinv-wl-product")+'"], form.vtajaxform[method=post][data-product_id="'+c(this).attr("data-tinv-wl-product")+'"]').each(function(){e.push(c(this))}),e.length||(c(n).closest("form.cart[method=post], form.vtajaxform[method=post]").each(function(){e.push(c(this))}),e.length||e.push(c("form.cart[method=post]"))),c('.tinv-wraper[data-tinvwl_product_id="'+c(this).attr("data-tinv-wl-product")+'"]').each(function(){e.push(c(this))}),c.each(e,function(t,i){c(i).find("input:not(:disabled), select:not(:disabled), textarea:not(:disabled)").each(function(){function o(t,i){if("object"!==_typeof(i))return i;for(var n in void 0===t&&(t={}),i)if(""===n){var e=-1;for(e in t);t[e=parseInt(e)+1]=o(t[n],i[n])}else t[n]=o(t[n],i[n]);return t}var t,i=c(this).attr("name"),n=c(this).attr("type"),e=c(this).val(),a=10;if("button"!==n&&void 0!==i){for(;/^(.+)\[([^\[\]]*?)\]$/.test(i)&&0<a;){var s,l=i.match(/^(.+)\[([^\[\]]*?)\]$/);3===l.length&&((s={})[l[2]]=e,e=s),i=l[1],a--}"file"!==n||(t=c(this)[0].files)&&r.append(i,t[0]),"checkbox"===n||"radio"===n?c(this).is(":checked")&&(e.length||"object"===_typeof(e)||(e=!0),d.form[i]=o(d.form[i],e)):d.form[i]=o(d.form[i],e)}})}),d=o.onPrepareDataAction.call(n,n,d)||d,c.each(d,function(n,t){"form"===n?c.each(t,function(t,i){"object"===_typeof(i)&&(i=JSON.stringify(i)),r.append(n+"["+t+"]",i)}):r.append(n,t)}),c.ajax({url:o.api_url,method:"POST",contentType:!1,processData:!1,data:r}).done(function(t){if(c("body").trigger("tinvwl_wishlist_ajax_response",[this,t]),o.onDialogHide.call(n.tinvwl_dialog,n),"object"===_typeof(t))for(var i in t)"function"==typeof o.onAction[i]&&o.onAction[i].call(n,t[i]);else"function"==typeof o.onAction.msg&&o.onAction.msg.call(n,t)})},c.extend(!0,{},i,t));return c(this).each(function(){if(!c(this).attr("data-tinv-wl-list"))return!1;var t,e;o.dialogbox&&o.dialogbox.length&&(this.tinvwl_dialog=o.dialogbox),this.tinvwl_dialog||(this.tinvwl_dialog=o.onGetDialogBox.call(this)),this.tinvwl_dialog||(t=c(this).nextAll(o.class.dialogbox).eq(0)).length&&(this.tinvwl_dialog=t),this.tinvwl_dialog&&(o.onPrepareDialogBox.call(this.tinvwl_dialog),"function"!=typeof this.tinvwl_dialog.update_list&&(this.tinvwl_dialog.update_list=function(t){var n=c(this).find(o.class.select).eq(0);c(this).find(o.class.newtitle).hide().val(""),n.html(""),c.each(t,function(t,i){o.onCreateWishList.call(n,i)}),o.text_create&&o.onCreateWishList.call(n,{ID:"",title:o.text_create,in:!1}),o.onMultiProductAlreadyIn.call(n,t),o.onSelectWishList.call(n,t),c(this).find(o.class.newtitle).toggle(""===n.val())}),"function"!=typeof this.tinvwl_dialog.show_list&&(this.tinvwl_dialog.show_list=function(){var t=JSON.parse(c(this).attr("data-tinv-wl-list"))||[];t.length?(t=o.onPrepareList.call(t)||t,this.tinvwl_dialog.update_list(t),o.onDialogShow.call(this.tinvwl_dialog,this)):o.onActionProduct.call(this)}),c((e=this).tinvwl_dialog).find(o.class.dialogbutton).off("click").on("click",function(){var t,i=c(e.tinvwl_dialog).find(o.class.select),n=c(e.tinvwl_dialog).find(o.class.newtitle);i.val()||n.val()?o.onActionProduct.call(e,i.val(),n.val()):((t=n.is(":visible")?n:i).addClass("empty-name-wishlist"),window.setTimeout(function(){t.removeClass("empty-name-wishlist")},1e3))})),c(this).off("click").on("click",o.onClick),o.onInited.call(this,o)})},c(document).ready(function(){c("body").on("click keydown",".tinvwl_add_to_wishlist_button",function(t){if("keydown"===t.type){var i=void 0!==t.key?t.key:t.keyCode;if(!("Enter"===i||13===i||0<=["Spacebar"," "].indexOf(i)||32===i))return;t.preventDefault()}if(c("body").trigger("tinvwl_add_to_wishlist_button_click",[this]),c(this).is(".disabled-add-wishlist"))return t.preventDefault(),void window.alert(tinvwl_add_to_wishlist.i18n_make_a_selection_text);c(this).is(".inited-add-wishlist")||c(this).tinvwl_to_wishlist({onInited:function(t){c(this).addClass("inited-add-wishlist"),t.onClick.call(this)}})}),c("body").on("click keydown",'button[name="tinvwl-remove"]',function(t){if("keydown"===t.type){var i=void 0!==t.key?t.key:t.keyCode;if(!("Enter"===i||13===i||0<=["Spacebar"," "].indexOf(i)||32===i))return}t.preventDefault();var e=c(this);e.is(".inited-wishlist-action")||(e.addClass("inited-wishlist-action"),i={"tinvwl-product_id":e.val(),"tinvwl-action":"remove","tinvwl-security":tinvwl_add_to_wishlist.nonce,"tinvwl-paged":e.closest("form").data("tinvwl_paged"),"tinvwl-sharekey":e.closest("form").data("tinvwl_sharekey")},tinvwl_add_to_wishlist.wpml&&(i.lang=tinvwl_add_to_wishlist.wpml),tinvwl_add_to_wishlist.wpml_default&&(i.lang_default=tinvwl_add_to_wishlist.wpml_default),"1"==tinvwl_add_to_wishlist.stats&&(i.stats=tinvwl_add_to_wishlist.stats),c.ajax({url:tinvwl_add_to_wishlist.wc_ajax_url,method:"POST",cache:!1,data:i,beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",tinvwl_add_to_wishlist.nonce)}}).done(function(t){var i,n;c("body").trigger("tinvwl_wishlist_ajax_response",[this,t]),e.removeClass("inited-wishlist-action"),t.msg&&(i=c(t.msg).eq(0),c("body > .tinv-wishlist").length||c("body").append(c("<div>").addClass("tinv-wishlist")),c("body > .tinv-wishlist").append(i),d("body > .tinv-wishlist"),i.on("click",".tinv-close-modal, .tinvwl_button_close, .tinv-overlay",function(t){t.preventDefault(),i.remove()}),n=n||window.setTimeout(function(){i.remove(),n&&clearTimeout(n)},tinvwl_add_to_wishlist.popup_timer)),t.status&&(c("div.tinv-wishlist.woocommerce.tinv-wishlist-clear").replaceWith(t.content),c(".tinvwl-break-input").tinvwl_break_submit({selector:".tinvwl-break-input-filed"}),c(".tinvwl-break-checkbox").tinvwl_break_submit({selector:"table td input[type=checkbox]",validate:function(){return c(this).is(":checked")}}),jQuery.fn.tinvwl_get_wishlist_data()),t.wishlists_data&&l(JSON.stringify(t.wishlists_data))}))}),c("body").on("click keydown",'button[name="tinvwl-add-to-cart"]',function(t){if("keydown"===t.type){var i=void 0!==t.key?t.key:t.keyCode;if(!("Enter"===i||13===i||0<=["Spacebar"," "].indexOf(i)||32===i))return}t.preventDefault();var e=c(this);e.is(".inited-wishlist-action")||(e.addClass("inited-wishlist-action"),i={"tinvwl-product_id":e.val(),"tinvwl-action":"add_to_cart_single","tinvwl-security":tinvwl_add_to_wishlist.nonce,"tinvwl-paged":e.closest("form").data("tinvwl_paged"),"tinvwl-sharekey":e.closest("form").data("tinvwl_sharekey")},tinvwl_add_to_wishlist.wpml&&(i.lang=tinvwl_add_to_wishlist.wpml),tinvwl_add_to_wishlist.wpml_default&&(i.lang_default=tinvwl_add_to_wishlist.wpml_default),"1"==tinvwl_add_to_wishlist.stats&&(i.stats=tinvwl_add_to_wishlist.stats),c.ajax({url:tinvwl_add_to_wishlist.wc_ajax_url,method:"POST",cache:!1,data:i,beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",tinvwl_add_to_wishlist.nonce)}}).done(function(t){var i,n;c("body").trigger("tinvwl_wishlist_ajax_response",[this,t]),e.removeClass("inited-wishlist-action"),t.redirect&&(window.location.href=t.redirect),t.msg&&(i=c(t.msg).eq(0),c("body > .tinv-wishlist").length||c("body").append(c("<div>").addClass("tinv-wishlist")),c("body > .tinv-wishlist").append(i),d("body > .tinv-wishlist"),i.on("click",".tinv-close-modal, .tinvwl_button_close, .tinv-overlay",function(t){t.preventDefault(),i.remove()}),n=n||window.setTimeout(function(){i.remove(),n&&clearTimeout(n)},tinvwl_add_to_wishlist.popup_timer)),t.redirect||(c(document.body).trigger("wc_fragment_refresh"),c("div.tinv-wishlist.woocommerce.tinv-wishlist-clear").replaceWith(t.content),jQuery.fn.tinvwl_get_wishlist_data(),t.wishlists_data&&l(JSON.stringify(t.wishlists_data)))}))}),c("body").on("click keydown",'button[name="tinvwl-action-product_all"]',function(t){if("keydown"===t.type){var i=void 0!==t.key?t.key:t.keyCode;if(!("Enter"===i||13===i||0<=["Spacebar"," "].indexOf(i)||32===i))return}t.preventDefault();var e=c(this);e.is(".inited-wishlist-action")||(e.addClass("inited-wishlist-action"),i={"tinvwl-action":"add_to_cart_all","tinvwl-security":tinvwl_add_to_wishlist.nonce,"tinvwl-paged":e.closest("form").data("tinvwl_paged"),"tinvwl-sharekey":e.closest("form").data("tinvwl_sharekey")},tinvwl_add_to_wishlist.wpml&&(i.lang=tinvwl_add_to_wishlist.wpml),tinvwl_add_to_wishlist.wpml_default&&(i.lang_default=tinvwl_add_to_wishlist.wpml_default),"1"==tinvwl_add_to_wishlist.stats&&(i.stats=tinvwl_add_to_wishlist.stats),c.ajax({url:tinvwl_add_to_wishlist.wc_ajax_url,method:"POST",cache:!1,data:i,beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",tinvwl_add_to_wishlist.nonce)}}).done(function(t){var i,n;c("body").trigger("tinvwl_wishlist_ajax_response",[this,t]),e.removeClass("inited-wishlist-action"),t.redirect&&(window.location.href=t.redirect),t.msg&&(i=c(t.msg).eq(0),c("body > .tinv-wishlist").length||c("body").append(c("<div>").addClass("tinv-wishlist")),c("body > .tinv-wishlist").append(i),d("body > .tinv-wishlist"),i.on("click",".tinv-close-modal, .tinvwl_button_close, .tinv-overlay",function(t){t.preventDefault(),i.remove()}),n=n||window.setTimeout(function(){i.remove(),n&&clearTimeout(n)},tinvwl_add_to_wishlist.popup_timer)),t.redirect||(c(document.body).trigger("wc_fragment_refresh"),c("div.tinv-wishlist.woocommerce.tinv-wishlist-clear").replaceWith(t.content),jQuery.fn.tinvwl_get_wishlist_data(),t.wishlists_data&&l(JSON.stringify(t.wishlists_data)))}))}),c("body").on("click keydown",'button[name="tinvwl-action-product_apply"], button[name="tinvwl-action-product_selected"]',function(t){if("keydown"===t.type){var i=void 0!==t.key?t.key:t.keyCode;if(!("Enter"===i||13===i||0<=["Spacebar"," "].indexOf(i)||32===i))return}t.preventDefault();var e,n=[],o=(c('input[name="wishlist_pr[]"]:checked').each(function(){n.push(this.value)}),c(this));n.length&&("tinvwl-action-product_selected"===o.attr("name")||c("select#tinvwl_product_actions option").filter(":selected").val())?o.is(".inited-wishlist-action")||(o.addClass("inited-wishlist-action"),e="",e="tinvwl-action-product_selected"===o.attr("name")?"add_to_cart_selected":c("select#tinvwl_product_actions option").filter(":selected").val(),i={"tinvwl-products":n,"tinvwl-action":e,"tinvwl-security":tinvwl_add_to_wishlist.nonce,"tinvwl-paged":o.closest("form").data("tinvwl_paged"),"tinvwl-sharekey":o.closest("form").data("tinvwl_sharekey")},tinvwl_add_to_wishlist.wpml&&(i.lang=tinvwl_add_to_wishlist.wpml),tinvwl_add_to_wishlist.wpml_default&&(i.lang_default=tinvwl_add_to_wishlist.wpml_default),"1"==tinvwl_add_to_wishlist.stats&&(i.stats=tinvwl_add_to_wishlist.stats),c.ajax({url:tinvwl_add_to_wishlist.wc_ajax_url,method:"POST",cache:!1,data:i,beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",tinvwl_add_to_wishlist.nonce)}}).done(function(t){var i,n;c("body").trigger("tinvwl_wishlist_ajax_response",[this,t]),o.removeClass("inited-wishlist-action"),t.redirect&&(window.location.href=t.redirect),t.msg&&(i=c(t.msg).eq(0),c("body > .tinv-wishlist").length||c("body").append(c("<div>").addClass("tinv-wishlist")),c("body > .tinv-wishlist").append(i),d("body > .tinv-wishlist"),i.on("click",".tinv-close-modal, .tinvwl_button_close, .tinv-overlay",function(t){t.preventDefault(),i.remove()}),n=n||window.setTimeout(function(){i.remove(),n&&clearTimeout(n)},tinvwl_add_to_wishlist.popup_timer)),t.redirect||("add_to_cart_selected"===e&&c(document.body).trigger("wc_fragment_refresh"),c("div.tinv-wishlist.woocommerce.tinv-wishlist-clear").replaceWith(t.content),jQuery.fn.tinvwl_get_wishlist_data(),t.wishlists_data&&l(JSON.stringify(t.wishlists_data)))})):alert(window.tinvwl_add_to_wishlist.tinvwl_break_submit)}),c(document).on("hide_variation",".variations_form",function(t){var i=c('.tinvwl_add_to_wishlist_button:not(.tinvwl-loop)[data-tinv-wl-product="'+c(this).data("product_id")+'"]');if(i.attr("data-tinv-wl-productvariation",0),i.length&&i.attr("data-tinv-wl-list")){var n=JSON.parse(i.attr("data-tinv-wl-list")),e=!1,o="1"==window.tinvwl_add_to_wishlist.simple_flow;for(a in n)n[a].hasOwnProperty("in")&&Array.isArray(n[a].in)&&-1<(n[a].in||[]).indexOf(0)&&(e=!0);i.toggleClass("tinvwl-product-in-list",e).toggleClass("tinvwl-product-make-remove",e&&o).attr("data-tinv-wl-action",e&&o?"remove":"addto")}if(i.length&&i.attr("data-tinv-wl-product-stats")){i.find("span.tinvwl-product-stats").remove();var a,s=JSON.parse(i.attr("data-tinv-wl-product-stats"));for(a in s)-1<a.indexOf(0)&&(e=!0,c("body").trigger("tinvwl_wishlist_product_stats",[i,e]),i.append('<span class="tinvwl-product-stats">'+s[a]+"</span>"))}i.length&&!tinvwl_add_to_wishlist.allow_parent_variable&&(t.preventDefault(),i.addClass("disabled-add-wishlist"))}),c(document).on("show_variation",".variations_form",function(t,i,n){var e=c('.tinvwl_add_to_wishlist_button:not(.tinvwl-loop)[data-tinv-wl-product="'+c(this).data("product_id")+'"]');if(e.attr("data-tinv-wl-productvariation",i.variation_id),e.length&&e.attr("data-tinv-wl-list")){var o=JSON.parse(e.attr("data-tinv-wl-list")),a=!1,s="1"==window.tinvwl_add_to_wishlist.simple_flow;for(l in o)o[l].hasOwnProperty("in")&&Array.isArray(o[l].in)&&-1<(o[l].in||[]).indexOf(i.variation_id)&&(a=!0);e.toggleClass("tinvwl-product-in-list",a).toggleClass("tinvwl-product-make-remove",a&&s).attr("data-tinv-wl-action",a&&s?"remove":"addto")}if(e.length&&e.attr("data-tinv-wl-product-stats")){e.find("span.tinvwl-product-stats").remove();var l,d=JSON.parse(e.attr("data-tinv-wl-product-stats"));for(l in d)-1<l.indexOf(i.variation_id)&&(a=!0,c("body").trigger("tinvwl_wishlist_product_stats",[e,a]),e.append('<span class="tinvwl-product-stats">'+d[l]+"</span>"))}t.preventDefault(),e.removeClass("disabled-add-wishlist")}),c(window).on("storage onstorage",function(t){a===t.originalEvent.key&&localStorage.getItem(a)!==sessionStorage.getItem(a)&&(!localStorage.getItem(a)||"object"===_typeof(t=JSON.parse(localStorage.getItem(a)))&&null!==t&&(t.hasOwnProperty("products")||t.hasOwnProperty("counter"))&&l(localStorage.getItem(a)))});var i=[],n=!1,t=(c("a.tinvwl_add_to_wishlist_button").each(function(){"undefined"!==c(this).data("tinv-wl-product")&&c(this).data("tinv-wl-product")&&i.push(c(this).data("tinv-wl-product"))}),c(".wishlist_products_counter_number").each(function(){n=!0}),c.fn.tinvwl_get_wishlist_data=function(){if(o&&(tinvwl_add_to_wishlist.update_wishlists_data&&localStorage.setItem(a,""),localStorage.getItem(a))){var t=JSON.parse(localStorage.getItem(a));if("object"===_typeof(t)&&null!==t&&(t.hasOwnProperty("products")||t.hasOwnProperty("counter"))&&(!t.hasOwnProperty("lang")&&!tinvwl_add_to_wishlist.wpml||tinvwl_add_to_wishlist.wpml&&t.lang===tinvwl_add_to_wishlist.wpml))return void s(t)}tinvwl_add_to_wishlist.block_ajax_wishlists_data||(i.length||n)&&(t={"tinvwl-action":"get_data","tinvwl-security":tinvwl_add_to_wishlist.nonce},tinvwl_add_to_wishlist.wpml&&(t.lang=tinvwl_add_to_wishlist.wpml),tinvwl_add_to_wishlist.wpml_default&&(t.lang_default=tinvwl_add_to_wishlist.wpml_default),"1"==tinvwl_add_to_wishlist.stats&&(t.stats=tinvwl_add_to_wishlist.stats),c.ajax({url:tinvwl_add_to_wishlist.wc_ajax_url,method:"POST",cache:!1,data:t,beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",tinvwl_add_to_wishlist.nonce)}}).done(function(t){c("body").trigger("tinvwl_wishlist_ajax_response",[this,t]),t.wishlists_data&&l(JSON.stringify(t.wishlists_data))}))},c.fn.tinvwl_get_wishlist_data(),new MutationObserver(function(t){i=[],t.forEach(function(t){t=t.addedNodes;null!==t&&c(t).each(function(){var t=c(this).find(".tinvwl_add_to_wishlist_button");t.length&&t.each(function(){"undefined"!==c(this).data("tinv-wl-product")&&c(this).data("tinv-wl-product")&&i.push(c(this).data("tinv-wl-product"))})})}),i.length&&c.fn.tinvwl_get_wishlist_data()})),e=document.body;t.observe(e,{childList:!0,subtree:!0})});var o=!0,a=tinvwl_add_to_wishlist.hash_key;try{o="sessionStorage"in window&&null!==window.sessionStorage,window.sessionStorage.setItem("ti","test"),window.sessionStorage.removeItem("ti"),window.localStorage.setItem("ti","test"),window.localStorage.removeItem("ti")}catch(t){o=!1}function s(t){var s="1"==window.tinvwl_add_to_wishlist.simple_flow,i=((s||t.stats&&"1"==tinvwl_add_to_wishlist.stats)&&c("a.tinvwl_add_to_wishlist_button").each(function(){s&&c(this).removeClass("tinvwl-product-make-remove").removeClass("tinvwl-product-already-on-wishlist").removeClass("tinvwl-product-in-list").attr("data-tinv-wl-action","addto").attr("data-tinv-wl-list","[]"),t.stats&&c(this).find("span.tinvwl-product-stats").remove()}),c("body").trigger("tinvwl_wishlist_mark_products",[t]),c.each(t.products,function(t,o){var a=t;c('a.tinvwl_add_to_wishlist_button[data-tinv-wl-product="'+a+'"]').each(function(){var i,t=parseInt(c(this).attr("data-tinv-wl-productvariation")),n=c(this).data("tinv-wl-productvariations")||[],e=!1;for(i in o)o[i].hasOwnProperty("in")&&Array.isArray(o[i].in)&&(-1<(o[i].in||[]).indexOf(a)||-1<(o[i].in||[]).indexOf(t)||n.some(function(t){return 0<=(o[i].in||[]).indexOf(t)}))&&(e=!0);c("body").trigger("tinvwl_wishlist_product_marked",[this,e]),c(this).attr("data-tinv-wl-list",JSON.stringify(o)).toggleClass("tinvwl-product-in-list",e).toggleClass("tinvwl-product-make-remove",e&&s).attr("data-tinv-wl-action",e&&s?"remove":"addto")})}),t.stats&&"1"==tinvwl_add_to_wishlist.stats&&c.each(t.stats,function(t,n){c('a.tinvwl_add_to_wishlist_button[data-tinv-wl-product="'+t+'"]').each(function(){c(this).attr("data-tinv-wl-product-stats",JSON.stringify(n));var t,i=parseInt(c(this).attr("data-tinv-wl-productvariation"));for(t in n)-1<t.indexOf(i)&&(c("body").trigger("tinvwl_wishlist_product_stats",[this,!0]),c(this).append('<span class="tinvwl-product-stats">'+n[t]+"</span>"))})}),t.counter);"1"==window.tinvwl_add_to_wishlist.hide_zero_counter&&0===i&&(i="false"),jQuery("i.wishlist-icon").addClass("added"),"false"!==i?(jQuery(".wishlist_products_counter_number, body.theme-woostify .wishlist-item-count").html(i),jQuery("i.wishlist-icon").attr("data-icon-label",i)):(jQuery(".wishlist_products_counter_number, body.theme-woostify .wishlist-item-count").html("").closest("span.wishlist-counter-with-products").removeClass("wishlist-counter-with-products"),jQuery("i.wishlist-icon").removeAttr("data-icon-label")),i=!("0"==i||"false"==i),jQuery(".wishlist_products_counter").toggleClass("wishlist-counter-with-products",i),setTimeout(function(){jQuery("i.wishlist-icon").removeClass("added")},500)}function l(t){o&&(localStorage.setItem(a,t),sessionStorage.setItem(a,t),s(JSON.parse(t)))}function d(t){var t=c(t).find("select, input, textarea, button, a").filter(":visible"),i=t.first(),n=t.last();i.focus().blur(),n.on("keydown",function(t){9!==t.which||t.shiftKey||(t.preventDefault(),i.focus())}),i.on("keydown",function(t){9===t.which&&t.shiftKey&&(t.preventDefault(),n.focus())})}}(jQuery),function(e){e(document).ready(function(){if(e(".tinv-lists-nav").each(function(){e(this).html().trim().length||e(this).remove()}),e("body").on("click",".social-buttons .social:not(.social-email,.social-whatsapp,.social-clipboard)",function(t){var i=window.open(e(this).attr("href"),e(this).attr("title"),"width=420,height=320,resizable=yes,scrollbars=yes,status=yes");i&&(i.focus(),t.preventDefault())}),"undefined"!=typeof ClipboardJS){new ClipboardJS(".social-buttons .social.social-clipboard",{text:function(t){return t.getAttribute("href")}}).on("success",function(t){showTooltip(t.trigger,tinvwl_add_to_wishlist.tinvwl_clipboard)});for(var t=document.querySelectorAll(".social-buttons .social.social-clipboard"),i=0;i<t.length;i++)t[i].addEventListener("mouseleave",clearTooltip),t[i].addEventListener("blur",clearTooltip)}e("body").on("click",".social-buttons .social.social-clipboard",function(t){t.preventDefault()}),e("body").on("click",".tinv-wishlist .tinv-overlay, .tinv-wishlist .tinv-close-modal, .tinv-wishlist .tinvwl_button_close",function(t){t.preventDefault(),e(this).parents(".tinv-modal:first").removeClass("tinv-modal-open"),e("body").trigger("tinvwl_modal_closed",[this])}),e("body").on("click",".tinv-wishlist .tinvwl-btn-onclick",function(t){e(this).data("url")&&(t.preventDefault(),window.location=e(this).data("url"))});var n=e(".tinv-wishlist .navigation-button");n.length&&n.each(function(){var t=e(this).find("> li");t.length<5&&t.parent().addClass("tinvwl-btns-count-"+t.length)}),e(".tinv-login .showlogin").off("click").on("click",function(t){t.preventDefault(),e(this).closest(".tinv-login").find(".login").toggle()}),e(".tinv-wishlist table.tinvwl-table-manage-list tfoot td").each(function(){e(this).toggle(!!e(this).children().not(".look_in").length||!!e(this).children(".look_in").children().length)})})}(jQuery),function(e){e.fn.tinvwl_break_submit=function(t){var n=e.extend(!0,{},{selector:"input, select, textarea",ifempty:!0,invert:!1,validate:function(){return e(this).val()},rule:function(){var t=e(this).parents("form").eq(0).find(n.selector),i=n.invert;return 0===t.length?n.ifempty:(t.each(function(){i&&!n.invert||!i&&n.invert||(i=Boolean(n.validate.call(e(this))))}),i)}},t);return e(this).each(function(){e(this).on("click",function(t){var i=[];void 0!==e(this).attr("tinvwl_break_submit")&&(i=e(this).attr("tinvwl_break_submit").split(",")),-1!==jQuery.inArray(n.selector,i)&&(i=[]),n.rule.call(e(this))||0!==i.length||(alert(window.tinvwl_add_to_wishlist.tinvwl_break_submit),t.preventDefault()),i.push(n.selector),e(this).attr("tinvwl_break_submit",i),n.rule.call(e(this))&&e(this).removeAttr("tinvwl_break_submit")})})},e(document).ready(function(){e("body").on("click",".global-cb",function(){e(this).closest("table").eq(0).find(".product-cb input[type=checkbox], .wishlist-cb input[type=checkbox]").prop("checked",e(this).is(":checked"))})})}(jQuery);
|
includes/api/ajax.php
DELETED
@@ -1,284 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
// Init
|
4 |
-
// -----------------------------------------------------------------------
|
5 |
-
define( 'DOING_AJAX', true );
|
6 |
-
define( 'SHORTINIT', true );
|
7 |
-
|
8 |
-
// WP Load
|
9 |
-
// -----------------------------------------------------------------------
|
10 |
-
|
11 |
-
function tinvwl_scan_dir( $path, $filename ) {
|
12 |
-
$path = rtrim( $path, '/' );
|
13 |
-
$filepath = '';
|
14 |
-
|
15 |
-
if ( $path && $filename ) {
|
16 |
-
$m = count( explode( DIRECTORY_SEPARATOR, $path ) );
|
17 |
-
|
18 |
-
$i = 0;
|
19 |
-
while ( $i < $m - 1 ) {
|
20 |
-
if ( file_exists( $path . DIRECTORY_SEPARATOR . $filename ) ) {
|
21 |
-
$filepath = $path . DIRECTORY_SEPARATOR . $filename;
|
22 |
-
break;
|
23 |
-
}
|
24 |
-
$path = dirname( $path );
|
25 |
-
$i ++;
|
26 |
-
}
|
27 |
-
}
|
28 |
-
|
29 |
-
return $filepath;
|
30 |
-
}
|
31 |
-
|
32 |
-
$config_file = tinvwl_scan_dir( dirname( dirname( dirname( __FILE__ ) ) ), 'wp-config.php' );
|
33 |
-
$load_file = tinvwl_scan_dir( dirname( dirname( dirname( __FILE__ ) ) ), 'wp-load.php' );
|
34 |
-
|
35 |
-
if ( file_exists( $config_file ) ) {
|
36 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
37 |
-
@require( $config_file );
|
38 |
-
}
|
39 |
-
if ( defined( 'ABSPATH' ) ) {
|
40 |
-
require( ABSPATH . '/wp-load.php' );
|
41 |
-
}
|
42 |
-
} elseif ( file_exists( $load_file ) ) {
|
43 |
-
require( $load_file );
|
44 |
-
}
|
45 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
46 |
-
exit;
|
47 |
-
}
|
48 |
-
|
49 |
-
wp_plugin_directory_constants();
|
50 |
-
require_once( ABSPATH . WPINC . '/class-wp-user.php' );
|
51 |
-
require_once( ABSPATH . WPINC . '/class-wp-roles.php' );
|
52 |
-
require_once( ABSPATH . WPINC . '/class-wp-role.php' );
|
53 |
-
require_once( ABSPATH . WPINC . '/class-wp-session-tokens.php' );
|
54 |
-
require_once( ABSPATH . WPINC . '/class-wp-user-meta-session-tokens.php' );
|
55 |
-
require_once( ABSPATH . WPINC . '/formatting.php' );
|
56 |
-
require_once( ABSPATH . WPINC . '/capabilities.php' );
|
57 |
-
//require_once ( ABSPATH . WPINC . '/query.php' ); // - might be useful
|
58 |
-
require_once( ABSPATH . WPINC . '/user.php' );
|
59 |
-
if ( file_exists( ABSPATH . WPINC . '/class-wp-application-passwords.php' ) ) {
|
60 |
-
require_once( ABSPATH . WPINC . '/class-wp-application-passwords.php' ); // From WP 5.6.0
|
61 |
-
}
|
62 |
-
require_once( ABSPATH . WPINC . '/meta.php' );
|
63 |
-
|
64 |
-
wp_cookie_constants();
|
65 |
-
|
66 |
-
require_once( ABSPATH . WPINC . '/vars.php' );
|
67 |
-
require_once( ABSPATH . WPINC . '/kses.php' );
|
68 |
-
require_once( ABSPATH . WPINC . '/rest-api.php' );
|
69 |
-
require_once( ABSPATH . WPINC . '/pluggable.php' );
|
70 |
-
|
71 |
-
// Get the nonce.
|
72 |
-
if ( isset( $_SERVER['HTTP_X_WP_NONCE'] ) ) {
|
73 |
-
$nonce = $_SERVER['HTTP_X_WP_NONCE'];
|
74 |
-
} else {
|
75 |
-
wp_send_json( array( 'error' => 'Forbidden: unauthorized request.' ), 403 );
|
76 |
-
}
|
77 |
-
|
78 |
-
if ( is_user_logged_in() ) {
|
79 |
-
// Check the nonce.
|
80 |
-
$result = wp_verify_nonce( $nonce, 'wp_rest' );
|
81 |
-
|
82 |
-
if ( ! $result ) {
|
83 |
-
wp_send_json( array( 'error' => 'Forbidden: wrong nonce.' ), 403 );
|
84 |
-
}
|
85 |
-
}
|
86 |
-
|
87 |
-
// Response headers
|
88 |
-
@header( 'X-Robots-Tag: noindex' );
|
89 |
-
send_nosniff_header();
|
90 |
-
nocache_headers();
|
91 |
-
|
92 |
-
// DB query.
|
93 |
-
global $wpdb;
|
94 |
-
|
95 |
-
$table = sprintf( '%s%s', $wpdb->prefix, 'tinvwl_items' );
|
96 |
-
$table_lists = sprintf( '%s%s', $wpdb->prefix, 'tinvwl_lists' );
|
97 |
-
$table_stats = sprintf( '%s%s', $wpdb->prefix, 'tinvwl_analytics' );
|
98 |
-
$table_translations = sprintf( '%s%s', $wpdb->prefix, 'icl_translations' );
|
99 |
-
$table_languages = sprintf( '%s%s', $wpdb->prefix, 'icl_languages' );
|
100 |
-
$lang = filter_input( INPUT_POST, 'lang', FILTER_SANITIZE_STRING );
|
101 |
-
$lang_default = filter_input( INPUT_POST, 'lang_default', FILTER_SANITIZE_STRING );
|
102 |
-
$stats = filter_input( INPUT_POST, 'stats', FILTER_SANITIZE_STRING );
|
103 |
-
|
104 |
-
$data = $products = $wishlists = $results = $analytics = array();
|
105 |
-
|
106 |
-
$share_key = false;
|
107 |
-
|
108 |
-
if ( is_user_logged_in() ) {
|
109 |
-
$data['author'] = get_current_user_id();
|
110 |
-
} else {
|
111 |
-
$share_key = filter_input( INPUT_COOKIE, 'tinv_wishlistkey' );
|
112 |
-
}
|
113 |
-
|
114 |
-
if ( ( isset( $data['author'] ) && $data['author'] ) || $share_key ) {
|
115 |
-
|
116 |
-
$default = array(
|
117 |
-
'count' => 99999,
|
118 |
-
'field' => null,
|
119 |
-
'offset' => 0,
|
120 |
-
'order' => 'DESC',
|
121 |
-
'order_by' => 'date',
|
122 |
-
'external' => true,
|
123 |
-
'sql' => '',
|
124 |
-
);
|
125 |
-
|
126 |
-
foreach ( $default as $_k => $_v ) {
|
127 |
-
if ( array_key_exists( $_k, $data ) ) {
|
128 |
-
$default[ $_k ] = $data[ $_k ];
|
129 |
-
unset( $data[ $_k ] );
|
130 |
-
}
|
131 |
-
}
|
132 |
-
|
133 |
-
$default['offset'] = absint( $default['offset'] );
|
134 |
-
$default['count'] = absint( $default['count'] );
|
135 |
-
|
136 |
-
if ( $lang ) {
|
137 |
-
$default['field'] = $table . '.ID, t.element_id AS product_id, t2.element_id AS variation_id, ' . $table . '.formdata,' . $table . '.author,' . $table . '.date,' . $table . '.quantity,' . $table . '.price,' . $table . '.in_stock,';
|
138 |
-
} else {
|
139 |
-
$default['field'] = $table . '.*, ';
|
140 |
-
}
|
141 |
-
|
142 |
-
$default['field'] .= $table_lists . '.ID as wishlist_id, ' . $table_lists . '.status as wishlist_status, ' . $table_lists . '.title as wishlist_title, ' . $table_lists . '.share_key as wishlist_share_key';
|
143 |
-
|
144 |
-
$sql = "SELECT {$default[ 'field' ]} FROM `{$table}` INNER JOIN `{$table_lists}` ON `{$table}`.`wishlist_id` = `{$table_lists}`.`ID` AND `{$table_lists}`.`type` = 'default'";
|
145 |
-
|
146 |
-
if ( $share_key ) {
|
147 |
-
$sql .= " AND `{$table_lists}`.`share_key` = '{$share_key}'";
|
148 |
-
}
|
149 |
-
if ( $lang ) {
|
150 |
-
|
151 |
-
if ( $lang_default ) {
|
152 |
-
$lang = sprintf( "'%s'", implode( "', '", array( $lang, $lang_default ) ) );
|
153 |
-
} else {
|
154 |
-
$lang = "'" . $lang . "'";
|
155 |
-
}
|
156 |
-
|
157 |
-
$sql .= "LEFT JOIN {$table_translations} tr ON
|
158 |
-
{$table}.product_id = tr.element_id AND tr.element_type = 'post_product'
|
159 |
-
LEFT JOIN {$table_translations} tr2 ON
|
160 |
-
{$table}.variation_id != 0 AND {$table}.variation_id = tr2.element_id AND tr2.element_type = 'post_product_variation'
|
161 |
-
LEFT JOIN {$table_translations} t ON
|
162 |
-
tr.trid = t.trid AND t.element_type = 'post_product' AND t.language_code IN ({$lang})
|
163 |
-
LEFT JOIN {$table_translations} t2 ON
|
164 |
-
{$table}.variation_id != 0 AND tr2.trid = t2.trid AND t2.element_type = 'post_product_variation' AND t2.language_code IN ({$lang})
|
165 |
-
JOIN {$table_languages} l ON
|
166 |
-
(
|
167 |
-
t.language_code = l.code OR t2.language_code = l.code
|
168 |
-
) AND l.active = 1";
|
169 |
-
}
|
170 |
-
$where = '1';
|
171 |
-
|
172 |
-
if ( ! empty( $data ) && is_array( $data ) ) {
|
173 |
-
|
174 |
-
if ( array_key_exists( 'meta', $data ) ) {
|
175 |
-
$product_id = $variation_id = 0;
|
176 |
-
if ( array_key_exists( 'product_id', $data ) ) {
|
177 |
-
$product_id = $data['product_id'];
|
178 |
-
}
|
179 |
-
if ( array_key_exists( 'variation_id', $data ) ) {
|
180 |
-
$variation_id = $data['variation_id'];
|
181 |
-
}
|
182 |
-
$data['formdata'] = '';
|
183 |
-
unset( $data['meta'] );
|
184 |
-
}
|
185 |
-
|
186 |
-
foreach ( $data as $f => $v ) {
|
187 |
-
$s = is_array( $v ) ? ' IN ' : '=';
|
188 |
-
if ( is_array( $v ) ) {
|
189 |
-
foreach ( $v as $_f => $_v ) {
|
190 |
-
$v[ $_f ] = $wpdb->prepare( '%s', $_v );
|
191 |
-
}
|
192 |
-
$v = implode( ',', $v );
|
193 |
-
$v = "($v)";
|
194 |
-
} else {
|
195 |
-
$v = $wpdb->prepare( '%s', $v );
|
196 |
-
}
|
197 |
-
$data[ $f ] = sprintf( $table . '.' . '`%s`%s%s', $f, $s, $v );
|
198 |
-
}
|
199 |
-
|
200 |
-
$where = implode( ' AND ', $data );
|
201 |
-
|
202 |
-
$sql .= ' WHERE ' . $where;
|
203 |
-
}
|
204 |
-
|
205 |
-
$sql .= sprintf( ' GROUP BY `%s`.ID ORDER BY `%s` %s LIMIT %d,%d;', $table, $default['order_by'], $default['order'], $default['offset'], $default['count'] );
|
206 |
-
|
207 |
-
if ( ! empty( $default['sql'] ) ) {
|
208 |
-
$replacer = $replace = array();
|
209 |
-
$replace[0] = '{table}';
|
210 |
-
$replacer[0] = $table;
|
211 |
-
$replace[1] = '{where}';
|
212 |
-
$replacer[1] = $where;
|
213 |
-
|
214 |
-
foreach ( $default as $key => $value ) {
|
215 |
-
$i = count( $replace );
|
216 |
-
|
217 |
-
$replace[ $i ] = '{' . $key . '}';
|
218 |
-
$replacer[ $i ] = $value;
|
219 |
-
}
|
220 |
-
|
221 |
-
$sql = str_replace( $replace, $replacer, $default['sql'] );
|
222 |
-
}
|
223 |
-
|
224 |
-
$results = $wpdb->get_results( $sql, ARRAY_A );
|
225 |
-
|
226 |
-
if ( ! empty( $results ) ) {
|
227 |
-
foreach ( $results as $product ) {
|
228 |
-
$wishlists[ $product['wishlist_id'] ] = array(
|
229 |
-
'ID' => (int) $product['wishlist_id'],
|
230 |
-
'title' => $product['wishlist_title'],
|
231 |
-
'status' => $product['wishlist_status'],
|
232 |
-
'share_key' => $product['wishlist_share_key'],
|
233 |
-
'in' => array(),
|
234 |
-
);
|
235 |
-
|
236 |
-
}
|
237 |
-
|
238 |
-
foreach ( $wishlists as $wishlist ) {
|
239 |
-
|
240 |
-
foreach ( $results as $product ) {
|
241 |
-
if ( array_key_exists( $product['product_id'], $products ) ) {
|
242 |
-
$products[ $product['product_id'] ][ $wishlist['ID'] ]['in'][] = (int) $product['variation_id'];
|
243 |
-
} else {
|
244 |
-
$products[ $product['product_id'] ][ $wishlist['ID'] ] = $wishlist;
|
245 |
-
$products[ $product['product_id'] ][ $wishlist['ID'] ]['in'][] = (int) $product['variation_id'];
|
246 |
-
}
|
247 |
-
|
248 |
-
}
|
249 |
-
}
|
250 |
-
}
|
251 |
-
}
|
252 |
-
|
253 |
-
if ( $stats ) {
|
254 |
-
$stats_sql = "SELECT `A`.`product_id`, `A`.`variation_id`, COUNT(`B`.`ID`) AS `count` FROM `{$table_stats}` AS `A` LEFT JOIN `{$table}` AS `C` ON `C`.`wishlist_id` = `A`.`wishlist_id` AND `C`.`product_id` = `A`.`product_id` AND `C`.`variation_id` = `A`.`variation_id` LEFT JOIN `{$table_lists}` AS `B` ON `C`.`wishlist_id` = `B`.`ID` LEFT JOIN `{$table_lists}` AS `G` ON `C`.`wishlist_id` = `G`.`ID` AND `G`.`author` = 0 WHERE `A`.`product_id` > 0 GROUP BY `A`.`product_id`, `A`.`variation_id` HAVING `count` > 0 LIMIT 0, 9999999";
|
255 |
-
|
256 |
-
$stats_results = $wpdb->get_results( $stats_sql, ARRAY_A );
|
257 |
-
|
258 |
-
if ( ! empty( $stats_results ) ) {
|
259 |
-
foreach ( $stats_results as $product_stats ) {
|
260 |
-
$analytics[ $product_stats['product_id'] ][ $product_stats['variation_id'] ] = $product_stats['count'];
|
261 |
-
}
|
262 |
-
}
|
263 |
-
}
|
264 |
-
|
265 |
-
$count = is_array( $results ) ? array_sum( array_column( $results, 'quantity' ) ) : 0;
|
266 |
-
|
267 |
-
$response = array(
|
268 |
-
'products' => $products,
|
269 |
-
'counter' => $count,
|
270 |
-
);
|
271 |
-
|
272 |
-
if ( $lang ) {
|
273 |
-
$response['lang'] = $lang;
|
274 |
-
}
|
275 |
-
|
276 |
-
if ( $lang_default ) {
|
277 |
-
$response['lang_default'] = $lang_default;
|
278 |
-
}
|
279 |
-
|
280 |
-
if ( $stats ) {
|
281 |
-
$response['stats'] = $analytics;
|
282 |
-
}
|
283 |
-
|
284 |
-
wp_send_json( $response );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/api/yoasti18n/i18n-module-wordpressorg.php
CHANGED
@@ -1,74 +1,74 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* The Yoast i18n module with a connection to WordPress.org.
|
4 |
-
*
|
5 |
-
* @since 1.4.0
|
6 |
-
* @package TInvWishlist\API
|
7 |
-
*/
|
8 |
-
|
9 |
-
// If this file is called directly, abort.
|
10 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
11 |
-
die;
|
12 |
-
}
|
13 |
-
|
14 |
-
/**
|
15 |
-
* The Yoast i18n module with a connection to WordPress.org.
|
16 |
-
*/
|
17 |
-
class TInvWL_Yoast_I18n_WordPressOrg_V2 {
|
18 |
-
|
19 |
-
/**
|
20 |
-
* The i18n object that presents the user with the notification.
|
21 |
-
*
|
22 |
-
* @var yoast_i18n_v2
|
23 |
-
*/
|
24 |
-
protected $i18n;
|
25 |
-
|
26 |
-
/**
|
27 |
-
* Constructs the i18n module for wordpress.org. Required fields are the 'textdomain', 'plugin_name' and 'hook'
|
28 |
-
*
|
29 |
-
* @param array $args The settings for the i18n module.
|
30 |
-
*/
|
31 |
-
public function __construct( $args ) {
|
32 |
-
$args = $this->set_defaults( $args );
|
33 |
-
|
34 |
-
$this->i18n = new TInvWL_Yoast_I18n_V2( $args );
|
35 |
-
$this->set_api_url( $args['textdomain'] );
|
36 |
-
}
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Sets the default values for wordpress.org
|
40 |
-
*
|
41 |
-
* @param array $args The arguments to set defaults for.
|
42 |
-
*
|
43 |
-
* @return array The arguments with the arguments set.
|
44 |
-
*/
|
45 |
-
private function set_defaults( $args ) {
|
46 |
-
|
47 |
-
if ( ! isset( $args['glotpress_logo'] ) ) {
|
48 |
-
$args['glotpress_logo'] = 'https://plugins.svn.wordpress.org/' . $args['textdomain'] . '/assets/icon-128x128.
|
49 |
-
}
|
50 |
-
|
51 |
-
if ( ! isset( $args['register_url'] ) ) {
|
52 |
-
$args['register_url'] = 'https://translate.wordpress.org/projects/wp-plugins/' . $args['textdomain'] . '/';
|
53 |
-
}
|
54 |
-
|
55 |
-
if ( ! isset( $args['glotpress_name'] ) ) {
|
56 |
-
$args['glotpress_name'] = 'Translating WordPress';
|
57 |
-
}
|
58 |
-
|
59 |
-
if ( ! isset( $args['project_slug'] ) ) {
|
60 |
-
$args['project_slug'] = $args['textdomain'];
|
61 |
-
}
|
62 |
-
|
63 |
-
return $args;
|
64 |
-
}
|
65 |
-
|
66 |
-
/**
|
67 |
-
* Set the API URL on the i18n object.
|
68 |
-
*
|
69 |
-
* @param string $textdomain The textdomain to use for the API URL.
|
70 |
-
*/
|
71 |
-
private function set_api_url( $textdomain ) {
|
72 |
-
$this->i18n->set_api_url( 'https://translate.wordpress.org/api/projects/wp-plugins/' . $textdomain . '/stable/' );
|
73 |
-
}
|
74 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* The Yoast i18n module with a connection to WordPress.org.
|
4 |
+
*
|
5 |
+
* @since 1.4.0
|
6 |
+
* @package TInvWishlist\API
|
7 |
+
*/
|
8 |
+
|
9 |
+
// If this file is called directly, abort.
|
10 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
11 |
+
die;
|
12 |
+
}
|
13 |
+
|
14 |
+
/**
|
15 |
+
* The Yoast i18n module with a connection to WordPress.org.
|
16 |
+
*/
|
17 |
+
class TInvWL_Yoast_I18n_WordPressOrg_V2 {
|
18 |
+
|
19 |
+
/**
|
20 |
+
* The i18n object that presents the user with the notification.
|
21 |
+
*
|
22 |
+
* @var yoast_i18n_v2
|
23 |
+
*/
|
24 |
+
protected $i18n;
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Constructs the i18n module for wordpress.org. Required fields are the 'textdomain', 'plugin_name' and 'hook'
|
28 |
+
*
|
29 |
+
* @param array $args The settings for the i18n module.
|
30 |
+
*/
|
31 |
+
public function __construct( $args ) {
|
32 |
+
$args = $this->set_defaults( $args );
|
33 |
+
|
34 |
+
$this->i18n = new TInvWL_Yoast_I18n_V2( $args );
|
35 |
+
$this->set_api_url( $args['textdomain'] );
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Sets the default values for wordpress.org
|
40 |
+
*
|
41 |
+
* @param array $args The arguments to set defaults for.
|
42 |
+
*
|
43 |
+
* @return array The arguments with the arguments set.
|
44 |
+
*/
|
45 |
+
private function set_defaults( $args ) {
|
46 |
+
|
47 |
+
if ( ! isset( $args['glotpress_logo'] ) ) {
|
48 |
+
$args['glotpress_logo'] = 'https://plugins.svn.wordpress.org/' . $args['textdomain'] . '/assets/icon-128x128.gif';
|
49 |
+
}
|
50 |
+
|
51 |
+
if ( ! isset( $args['register_url'] ) ) {
|
52 |
+
$args['register_url'] = 'https://translate.wordpress.org/projects/wp-plugins/' . $args['textdomain'] . '/';
|
53 |
+
}
|
54 |
+
|
55 |
+
if ( ! isset( $args['glotpress_name'] ) ) {
|
56 |
+
$args['glotpress_name'] = 'Translating WordPress';
|
57 |
+
}
|
58 |
+
|
59 |
+
if ( ! isset( $args['project_slug'] ) ) {
|
60 |
+
$args['project_slug'] = $args['textdomain'];
|
61 |
+
}
|
62 |
+
|
63 |
+
return $args;
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Set the API URL on the i18n object.
|
68 |
+
*
|
69 |
+
* @param string $textdomain The textdomain to use for the API URL.
|
70 |
+
*/
|
71 |
+
private function set_api_url( $textdomain ) {
|
72 |
+
$this->i18n->set_api_url( 'https://translate.wordpress.org/api/projects/wp-plugins/' . $textdomain . '/stable/' );
|
73 |
+
}
|
74 |
+
}
|
includes/wishlist.class.php
CHANGED
@@ -324,6 +324,7 @@ class TInvWL_Wishlist {
|
|
324 |
$wishlist['is_owner'] = $this->get_sharekey() === $wishlist['share_key']; // WPCS: loose comparison ok.
|
325 |
}
|
326 |
}
|
|
|
327 |
return $wishlist;
|
328 |
}
|
329 |
|
@@ -417,6 +418,15 @@ class TInvWL_Wishlist {
|
|
417 |
$wl['title'] = $this->default_name;
|
418 |
}
|
419 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
420 |
$wls[ $k ] = apply_filters( 'tinvwl_wishlist_get', $wl );
|
421 |
}
|
422 |
|
324 |
$wishlist['is_owner'] = $this->get_sharekey() === $wishlist['share_key']; // WPCS: loose comparison ok.
|
325 |
}
|
326 |
}
|
327 |
+
|
328 |
return $wishlist;
|
329 |
}
|
330 |
|
418 |
$wl['title'] = $this->default_name;
|
419 |
}
|
420 |
|
421 |
+
if ( is_array( $wl ) ) {
|
422 |
+
$wl['is_owner'] = false;
|
423 |
+
if ( is_user_logged_in() ) {
|
424 |
+
$wl['is_owner'] = get_current_user_id() == $wl['author']; // WPCS: loose comparison ok.
|
425 |
+
} else {
|
426 |
+
$wl['is_owner'] = $this->get_sharekey() === $wl['share_key']; // WPCS: loose comparison ok.
|
427 |
+
}
|
428 |
+
}
|
429 |
+
|
430 |
$wls[ $k ] = apply_filters( 'tinvwl_wishlist_get', $wl );
|
431 |
}
|
432 |
|
integrations/woocommerce-tm-extra-product-options.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
*
|
5 |
* @name WooCommerce TM Extra Product Options
|
6 |
*
|
7 |
-
* @version
|
8 |
*
|
9 |
* @slug woocommerce-tm-extra-product-options
|
10 |
*
|
@@ -13,7 +13,7 @@
|
|
13 |
*/
|
14 |
|
15 |
// If this file is called directly, abort.
|
16 |
-
if (!defined('ABSPATH')) {
|
17 |
exit;
|
18 |
}
|
19 |
|
@@ -24,24 +24,24 @@ $slug = "woocommerce-tm-extra-product-options";
|
|
24 |
|
25 |
$name = "WooCommerce TM Extra Product Options";
|
26 |
|
27 |
-
$available = (defined('THEMECOMPLETE_EPO_VERSION') || defined('TM_EPO_VERSION'));
|
28 |
|
29 |
-
$tinvwl_integrations = is_array($tinvwl_integrations) ? $tinvwl_integrations : [];
|
30 |
|
31 |
-
$tinvwl_integrations[$slug] = array(
|
32 |
-
'name'
|
33 |
'available' => $available,
|
34 |
);
|
35 |
|
36 |
-
if (!tinv_get_option('integrations', $slug)) {
|
37 |
return;
|
38 |
}
|
39 |
|
40 |
-
if (
|
41 |
return;
|
42 |
}
|
43 |
|
44 |
-
if (!function_exists('tinv_wishlist_metasupport_woocommerce_tm_extra_product_options')) {
|
45 |
|
46 |
/**
|
47 |
* Set description for meta WooCommerce TM Extra Product Options
|
@@ -52,45 +52,46 @@ if (!function_exists('tinv_wishlist_metasupport_woocommerce_tm_extra_product_opt
|
|
52 |
*
|
53 |
* @return array
|
54 |
*/
|
55 |
-
function tinv_wishlist_metasupport_woocommerce_tm_extra_product_options($meta, $product_id, $variation_id)
|
56 |
-
|
57 |
-
|
58 |
-
$
|
59 |
-
$
|
60 |
-
$
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
if ($api->is_valid_options($has_epo)) {
|
65 |
$post_data = array();
|
66 |
-
foreach ($meta as $key => $value) {
|
67 |
-
$
|
|
|
68 |
}
|
|
|
69 |
$post_data['add-to-cart'] = $meta['tcaddtocart']['display'];
|
70 |
-
$post_data['product_id']
|
71 |
-
if ($variation_id) {
|
72 |
$post_data['variation_id'] = $variation_id;
|
73 |
}
|
74 |
$post_data['quantity'] = 1;
|
75 |
|
76 |
-
$cart_class = version_compare($version, '4.8.0', '<') ? $core : $cart;
|
77 |
|
78 |
-
$cart_item = $cart_class->add_cart_item_data_helper(array(), $product_id, $post_data);
|
79 |
-
if ('
|
80 |
-
$cart_item['quantity']
|
81 |
-
$cart_item['data']
|
82 |
$cart_item['tm_cart_item_key'] = '';
|
83 |
-
$cart_item['product_id']
|
84 |
-
$item_data
|
85 |
|
86 |
-
foreach ($item_data as $key => $data) {
|
87 |
// Set hidden to true to not display meta on cart.
|
88 |
-
if (!empty($data['hidden'])) {
|
89 |
-
unset($item_data[$key]);
|
90 |
continue;
|
91 |
}
|
92 |
-
$item_data[$key]['key']
|
93 |
-
$item_data[$key]['display'] = !empty($data['display']) ? $data['display'] : $data['value'];
|
94 |
}
|
95 |
|
96 |
return $item_data;
|
@@ -103,112 +104,111 @@ if (!function_exists('tinv_wishlist_metasupport_woocommerce_tm_extra_product_opt
|
|
103 |
return $meta;
|
104 |
}
|
105 |
|
106 |
-
add_filter('tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_woocommerce_tm_extra_product_options', 10, 3);
|
107 |
} // End if().
|
108 |
|
109 |
-
if (!function_exists('tinvwl_row_woocommerce_tm_extra_product_options')) {
|
110 |
|
111 |
/**
|
112 |
* Add rows for sub product for WooCommerce TM Extra Product Options
|
113 |
*
|
114 |
* @param array $wl_product Wishlist Product.
|
115 |
-
* @param \
|
116 |
*/
|
117 |
-
function tinvwl_row_woocommerce_tm_extra_product_options($wl_product, $product)
|
118 |
-
|
119 |
-
|
120 |
-
$
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
return FALSE;
|
129 |
}
|
130 |
$global_price_array = $cpf_price_array['global'];
|
131 |
|
132 |
-
foreach ($global_price_array as $priorities) {
|
133 |
-
foreach ($priorities as $field) {
|
134 |
-
foreach ($field['sections'] as $section_id => $section) {
|
135 |
-
if (isset($section['elements'])) {
|
136 |
-
foreach ($section['elements'] as $element) {
|
137 |
-
if ('product' === $element['type']) {
|
138 |
-
$current_tmcp_post_fields = array_intersect_key($wl_product['meta'], array_flip(array($element['name_inc'])));
|
139 |
-
foreach ($current_tmcp_post_fields as $attribute => $key) {
|
140 |
-
if (isset($wl_product['meta'][$attribute . '_quantity'])) {
|
141 |
-
if (empty($wl_product['meta'][$attribute . '_quantity'])) {
|
142 |
continue;
|
143 |
}
|
144 |
}
|
145 |
|
146 |
-
$_product = wc_get_product($key);
|
147 |
|
148 |
-
$product_url
|
149 |
$product_image = $_product->get_image();
|
150 |
-
$product_title = is_callable(array(
|
151 |
$_product,
|
152 |
'get_name'
|
153 |
-
)) ? $_product->get_name() : $_product->get_title();
|
154 |
|
155 |
$product_price = '';
|
156 |
|
157 |
-
if ($element['priced_individually']) {
|
158 |
$product_price = $_product->get_price();
|
159 |
}
|
160 |
|
161 |
-
if ($element['discount']) {
|
162 |
-
$discount = wc_format_decimal((double)$element['discount'], wc_get_price_decimals());
|
163 |
|
164 |
-
if ($product_price && $element['discount']) {
|
165 |
|
166 |
-
$price = wc_format_decimal((double)$product_price, wc_get_price_decimals());
|
167 |
|
168 |
-
if ($element['discount_type'] == 'fixed') {
|
169 |
-
$product_price = max($price - $discount, 0);
|
170 |
} else {
|
171 |
-
$product_price = max($price * ((100 - $discount) / 100), 0);
|
172 |
}
|
173 |
|
174 |
}
|
175 |
}
|
176 |
|
177 |
-
$product_price = wc_price($product_price);
|
178 |
|
179 |
-
if ($_product->is_visible()) {
|
180 |
-
$product_image = sprintf('<a href="%s">%s</a>', esc_url($product_url), $product_image);
|
181 |
-
$product_title = sprintf('<a href="%s">%s</a>', esc_url($product_url), $product_title);
|
182 |
}
|
183 |
-
$product_title .= tinv_wishlist_get_item_data($_product, $wl_product);
|
184 |
|
185 |
$row_string = '<tr>';
|
186 |
-
$row_string .= ((!is_user_logged_in() || get_current_user_id() !== $wl_product['author']) ? ((!tinv_get_option('table', 'colm_checkbox')) ? '' : '<td colspan="1"></td>') : '<td colspan="' . ((!tinv_get_option('table', 'colm_checkbox')) ? '1' : '2') . '"></td>') . ' ';
|
187 |
-
$row_string .= ($element['show_image']) ? '<td class="product-thumbnail">%2$s</td>' : '<td class="product-thumbnail"> </td>';
|
188 |
|
189 |
-
$row_string .= ($element['show_title']) ? '<td class="product-name">%1$s</td>' : '<td class="product-name"> </td>';
|
190 |
|
191 |
-
if (tinv_get_option('product_table', 'colm_price')) {
|
192 |
-
$row_string .= ($product_price && $element['show_price'] && $element['priced_individually']) ? '<td class="product-price">%4$s × %6$s</td>' : '<td class="product-price">× %6$s</td>';
|
193 |
}
|
194 |
-
if (tinv_get_option('product_table', 'colm_date')) {
|
195 |
$row_string .= '<td class="product-date"> </td>';
|
196 |
}
|
197 |
-
if (tinv_get_option('product_table', 'colm_stock')) {
|
198 |
$row_string .= '<td class="product-stock">%5$s</td>';
|
199 |
}
|
200 |
-
if (tinv_get_option('product_table', 'colm_quantity')) {
|
201 |
$row_string .= '<td class="product-quantity"> </td>';
|
202 |
}
|
203 |
-
if (tinv_get_option('product_table', 'add_to_cart')) {
|
204 |
$row_string .= '<td class="product-action"> </td>';
|
205 |
}
|
206 |
$row_string .= '</tr>';
|
207 |
|
208 |
-
echo sprintf($row_string, is_callable(array(
|
209 |
$_product,
|
210 |
'get_name'
|
211 |
-
)) ? $_product->get_name() : $_product->get_title(), $product_image, $product_title, $product_price, '', $wl_product['meta'][$attribute . '_quantity']); // WPCS: xss ok.
|
212 |
|
213 |
}
|
214 |
}
|
@@ -221,10 +221,10 @@ if (!function_exists('tinvwl_row_woocommerce_tm_extra_product_options')) {
|
|
221 |
}
|
222 |
}
|
223 |
|
224 |
-
add_action('tinvwl_wishlist_row_after', 'tinvwl_row_woocommerce_tm_extra_product_options', 10, 2);
|
225 |
} // End if().
|
226 |
|
227 |
-
if (!function_exists('tinvwl_item_price_woocommerce_tm_extra_product_options')) {
|
228 |
|
229 |
/**
|
230 |
* Modify price for WooCommerce TM Extra Product Options
|
@@ -235,39 +235,44 @@ if (!function_exists('tinvwl_item_price_woocommerce_tm_extra_product_options'))
|
|
235 |
*
|
236 |
* @return string
|
237 |
*/
|
238 |
-
function tinvwl_item_price_woocommerce_tm_extra_product_options($price, $wl_product, $product)
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
$
|
243 |
-
$
|
244 |
-
$
|
245 |
-
|
246 |
-
|
|
|
|
|
|
|
|
|
|
|
247 |
$product_id = $wl_product['product_id'];
|
248 |
-
$has_epo
|
249 |
-
if ($api->is_valid_options($has_epo)) {
|
250 |
|
251 |
-
$cart_class = version_compare($version, '4.8.0', '<') ? $core : $cart;
|
252 |
|
253 |
-
$cart_item
|
254 |
$cart_item['quantity'] = 1;
|
255 |
-
$cart_item['data']
|
256 |
-
|
257 |
-
$product_price = apply_filters('wc_epo_add_cart_item_original_price', $cart_item['data']->get_price(), $cart_item);
|
258 |
-
if (!empty($cart_item['tmcartepo'])) {
|
259 |
-
$to_currency = version_compare($version, '4.9.0', '<') ? tc_get_woocommerce_currency() : themecomplete_get_woocommerce_currency();
|
260 |
-
foreach ($cart_item['tmcartepo'] as $value) {
|
261 |
-
if (isset($value['price_per_currency']) && array_key_exists($to_currency, $value['price_per_currency'])) {
|
262 |
-
$value
|
263 |
$product_price += $value;
|
264 |
} else {
|
265 |
-
$product_price += floatval($value['price']);
|
266 |
}
|
267 |
}
|
268 |
}
|
269 |
|
270 |
-
$price = apply_filters('wc_tm_epo_ac_product_price', apply_filters('woocommerce_cart_item_price', $cart_class->get_price_for_cart($product_price, $cart_item, ''), $cart_item, ''), '', $cart_item, $product, $product_id);
|
271 |
}
|
272 |
}
|
273 |
}
|
@@ -275,55 +280,62 @@ if (!function_exists('tinvwl_item_price_woocommerce_tm_extra_product_options'))
|
|
275 |
return $price;
|
276 |
}
|
277 |
|
278 |
-
add_filter('tinvwl_wishlist_item_price', 'tinvwl_item_price_woocommerce_tm_extra_product_options', 10, 3);
|
279 |
} // End if().
|
280 |
|
281 |
-
add_filter('tinvwl_addtowishlist_prepare_form', 'tinvwl_meta_woocommerce_tm_extra_product_options', 10, 3);
|
282 |
|
283 |
-
function tinvwl_meta_woocommerce_tm_extra_product_options($meta, $post, $files)
|
284 |
-
{
|
285 |
|
286 |
-
if (defined('THEMECOMPLETE_EPO_VERSION') || defined('TM_EPO_VERSION')) {
|
287 |
-
foreach ($files as $name => $file) {
|
288 |
|
289 |
-
if (array_key_exists($name, $meta)) {
|
290 |
-
$upload = THEMECOMPLETE_EPO()->upload_file($file);
|
291 |
-
if (empty($upload['error']) && !empty($upload['file'])) {
|
292 |
-
$meta[$name] = wc_clean($upload['url']);
|
293 |
}
|
294 |
}
|
295 |
}
|
296 |
}
|
297 |
|
|
|
|
|
|
|
|
|
|
|
298 |
return $meta;
|
299 |
}
|
300 |
|
301 |
-
add_filter('tinvwl_product_prepare_meta', 'tinvwl_cart_meta_woocommerce_tm_extra_product_options');
|
302 |
|
303 |
-
function tinvwl_cart_meta_woocommerce_tm_extra_product_options($meta)
|
304 |
-
{
|
305 |
|
306 |
-
if (defined('THEMECOMPLETE_EPO_VERSION') || defined('TM_EPO_VERSION')) {
|
307 |
|
308 |
$files = $_FILES;
|
309 |
|
310 |
-
foreach ($files as $name => $file) {
|
311 |
|
312 |
-
if (!array_key_exists($name, $meta)) {
|
313 |
-
$upload = THEMECOMPLETE_EPO()->upload_file($file);
|
314 |
-
if (empty($upload['error']) && !empty($upload['file'])) {
|
315 |
-
$meta[$name] = wc_clean($upload['url']);
|
316 |
}
|
317 |
}
|
318 |
}
|
319 |
}
|
320 |
|
|
|
|
|
|
|
|
|
|
|
321 |
return $meta;
|
322 |
}
|
323 |
|
324 |
-
function tinvwl_add_to_wishlist_tm_extra_product_options()
|
325 |
-
|
326 |
-
wp_add_inline_script('tinvwl', "
|
327 |
jQuery('body').on('tinvwl_add_to_wishlist_button_click', function(e, el){
|
328 |
jQuery(el).closest('form.cart').each(function(){
|
329 |
if (jQuery(this).find('#tm-extra-product-options').length) {
|
@@ -341,7 +353,7 @@ function tinvwl_add_to_wishlist_tm_extra_product_options()
|
|
341 |
}
|
342 |
});
|
343 |
});
|
344 |
-
");
|
345 |
}
|
346 |
|
347 |
-
add_action('wp_enqueue_scripts', 'tinvwl_add_to_wishlist_tm_extra_product_options', 100, 1);
|
4 |
*
|
5 |
* @name WooCommerce TM Extra Product Options
|
6 |
*
|
7 |
+
* @version 6.0.5
|
8 |
*
|
9 |
* @slug woocommerce-tm-extra-product-options
|
10 |
*
|
13 |
*/
|
14 |
|
15 |
// If this file is called directly, abort.
|
16 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
17 |
exit;
|
18 |
}
|
19 |
|
24 |
|
25 |
$name = "WooCommerce TM Extra Product Options";
|
26 |
|
27 |
+
$available = ( defined( 'THEMECOMPLETE_EPO_VERSION' ) || defined( 'TM_EPO_VERSION' ) );
|
28 |
|
29 |
+
$tinvwl_integrations = is_array( $tinvwl_integrations ) ? $tinvwl_integrations : [];
|
30 |
|
31 |
+
$tinvwl_integrations[ $slug ] = array(
|
32 |
+
'name' => $name,
|
33 |
'available' => $available,
|
34 |
);
|
35 |
|
36 |
+
if ( ! tinv_get_option( 'integrations', $slug ) ) {
|
37 |
return;
|
38 |
}
|
39 |
|
40 |
+
if ( ! $available ) {
|
41 |
return;
|
42 |
}
|
43 |
|
44 |
+
if ( ! function_exists( 'tinv_wishlist_metasupport_woocommerce_tm_extra_product_options' ) ) {
|
45 |
|
46 |
/**
|
47 |
* Set description for meta WooCommerce TM Extra Product Options
|
52 |
*
|
53 |
* @return array
|
54 |
*/
|
55 |
+
function tinv_wishlist_metasupport_woocommerce_tm_extra_product_options( $meta, $product_id, $variation_id ) {
|
56 |
+
if ( array_key_exists( 'tcaddtocart', $meta ) && ( defined( 'THEMECOMPLETE_EPO_VERSION' ) || defined( 'TM_EPO_VERSION' ) ) ) {
|
57 |
+
$api = defined( 'THEMECOMPLETE_EPO_VERSION' ) ? THEMECOMPLETE_EPO_API() : TM_EPO_API();
|
58 |
+
$core = defined( 'THEMECOMPLETE_EPO_VERSION' ) ? THEMECOMPLETE_EPO() : TM_EPO();
|
59 |
+
$version = defined( 'THEMECOMPLETE_EPO_VERSION' ) ? THEMECOMPLETE_EPO_VERSION : TM_EPO_VERSION;
|
60 |
+
$cart = defined( 'THEMECOMPLETE_EPO_VERSION' ) ? new THEMECOMPLETE_EPO_Cart() : TM_EPO();
|
61 |
+
|
62 |
+
$has_epo = $api->has_options( $product_id );
|
63 |
+
if ( $api->is_valid_options( $has_epo ) ) {
|
|
|
64 |
$post_data = array();
|
65 |
+
foreach ( $meta as $key => $value ) {
|
66 |
+
// $value['display'] = ( is_object( json_decode( $value['display'] ) ) ) ? json_decode( $value['display'], true ) : $value['display'];
|
67 |
+
$post_data[ $key ] = $value['display'];
|
68 |
}
|
69 |
+
|
70 |
$post_data['add-to-cart'] = $meta['tcaddtocart']['display'];
|
71 |
+
$post_data['product_id'] = $product_id;
|
72 |
+
if ( $variation_id ) {
|
73 |
$post_data['variation_id'] = $variation_id;
|
74 |
}
|
75 |
$post_data['quantity'] = 1;
|
76 |
|
77 |
+
$cart_class = version_compare( $version, '4.8.0', '<' ) ? $core : $cart;
|
78 |
|
79 |
+
$cart_item = $cart_class->add_cart_item_data_helper( array(), $product_id, $post_data );
|
80 |
+
if ( 'no' == $core->tm_epo_hide_options_in_cart && 'advanced' != $core->tm_epo_cart_field_display && ! empty( $cart_item['tmcartepo'] ) ) {
|
81 |
+
$cart_item['quantity'] = 1;
|
82 |
+
$cart_item['data'] = wc_get_product( $variation_id ? $variation_id : $product_id );
|
83 |
$cart_item['tm_cart_item_key'] = '';
|
84 |
+
$cart_item['product_id'] = $product_id;
|
85 |
+
$item_data = $cart_class->get_item_data_array( array(), $cart_item );
|
86 |
|
87 |
+
foreach ( $item_data as $key => $data ) {
|
88 |
// Set hidden to true to not display meta on cart.
|
89 |
+
if ( ! empty( $data['hidden'] ) ) {
|
90 |
+
unset( $item_data[ $key ] );
|
91 |
continue;
|
92 |
}
|
93 |
+
$item_data[ $key ]['key'] = ! empty( $data['key'] ) ? $data['key'] : $data['name'];
|
94 |
+
$item_data[ $key ]['display'] = ! empty( $data['display'] ) ? $data['display'] : $data['value'];
|
95 |
}
|
96 |
|
97 |
return $item_data;
|
104 |
return $meta;
|
105 |
}
|
106 |
|
107 |
+
add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_woocommerce_tm_extra_product_options', 10, 3 );
|
108 |
} // End if().
|
109 |
|
110 |
+
if ( ! function_exists( 'tinvwl_row_woocommerce_tm_extra_product_options' ) ) {
|
111 |
|
112 |
/**
|
113 |
* Add rows for sub product for WooCommerce TM Extra Product Options
|
114 |
*
|
115 |
* @param array $wl_product Wishlist Product.
|
116 |
+
* @param \WC_Product $product Woocommerce Product.
|
117 |
*/
|
118 |
+
function tinvwl_row_woocommerce_tm_extra_product_options( $wl_product, $product ) {
|
119 |
+
if ( isset( $wl_product['meta'] ) && is_array( $wl_product['meta'] ) && array_key_exists( 'tcaddtocart', $wl_product['meta'] ) && ( defined( 'THEMECOMPLETE_EPO_VERSION' ) || defined( 'TM_EPO_VERSION' ) ) ) {
|
120 |
+
$api = defined( 'THEMECOMPLETE_EPO_VERSION' ) ? THEMECOMPLETE_EPO_API() : TM_EPO_API();
|
121 |
+
$core = defined( 'THEMECOMPLETE_EPO_VERSION' ) ? THEMECOMPLETE_EPO() : TM_EPO();
|
122 |
+
|
123 |
+
$has_epo = $api->has_options( $product->get_id() );
|
124 |
+
|
125 |
+
if ( $api->is_valid_options( $has_epo ) ) {
|
126 |
+
$cpf_price_array = $core->get_product_tm_epos( $product->get_id(), true, true, true );
|
127 |
+
if ( empty( $cpf_price_array ) ) {
|
128 |
+
return false;
|
|
|
129 |
}
|
130 |
$global_price_array = $cpf_price_array['global'];
|
131 |
|
132 |
+
foreach ( $global_price_array as $priorities ) {
|
133 |
+
foreach ( $priorities as $field ) {
|
134 |
+
foreach ( $field['sections'] as $section_id => $section ) {
|
135 |
+
if ( isset( $section['elements'] ) ) {
|
136 |
+
foreach ( $section['elements'] as $element ) {
|
137 |
+
if ( 'product' === $element['type'] ) {
|
138 |
+
$current_tmcp_post_fields = array_intersect_key( $wl_product['meta'], array_flip( array( substr( $element['name_inc'], 0, - 2 ) ) ) );
|
139 |
+
foreach ( $current_tmcp_post_fields as $attribute => $key ) {
|
140 |
+
if ( isset( $wl_product['meta'][ $attribute . '_quantity' ] ) ) {
|
141 |
+
if ( empty( $wl_product['meta'][ $attribute . '_quantity' ] ) ) {
|
142 |
continue;
|
143 |
}
|
144 |
}
|
145 |
|
146 |
+
$_product = wc_get_product( $key );
|
147 |
|
148 |
+
$product_url = $_product->get_permalink();
|
149 |
$product_image = $_product->get_image();
|
150 |
+
$product_title = is_callable( array(
|
151 |
$_product,
|
152 |
'get_name'
|
153 |
+
) ) ? $_product->get_name() : $_product->get_title();
|
154 |
|
155 |
$product_price = '';
|
156 |
|
157 |
+
if ( $element['priced_individually'] ) {
|
158 |
$product_price = $_product->get_price();
|
159 |
}
|
160 |
|
161 |
+
if ( $element['discount'] ) {
|
162 |
+
$discount = wc_format_decimal( (double) $element['discount'], wc_get_price_decimals() );
|
163 |
|
164 |
+
if ( $product_price && $element['discount'] ) {
|
165 |
|
166 |
+
$price = wc_format_decimal( (double) $product_price, wc_get_price_decimals() );
|
167 |
|
168 |
+
if ( $element['discount_type'] == 'fixed' ) {
|
169 |
+
$product_price = max( $price - $discount, 0 );
|
170 |
} else {
|
171 |
+
$product_price = max( $price * ( ( 100 - $discount ) / 100 ), 0 );
|
172 |
}
|
173 |
|
174 |
}
|
175 |
}
|
176 |
|
177 |
+
$product_price = wc_price( $product_price );
|
178 |
|
179 |
+
if ( $_product->is_visible() ) {
|
180 |
+
$product_image = sprintf( '<a href="%s">%s</a>', esc_url( $product_url ), $product_image );
|
181 |
+
$product_title = sprintf( '<a href="%s">%s</a>', esc_url( $product_url ), $product_title );
|
182 |
}
|
183 |
+
$product_title .= tinv_wishlist_get_item_data( $_product, $wl_product );
|
184 |
|
185 |
$row_string = '<tr>';
|
186 |
+
$row_string .= ( ( ! is_user_logged_in() || get_current_user_id() !== $wl_product['author'] ) ? ( ( ! tinv_get_option( 'table', 'colm_checkbox' ) ) ? '' : '<td colspan="1"></td>' ) : '<td colspan="' . ( ( ! tinv_get_option( 'table', 'colm_checkbox' ) ) ? '1' : '2' ) . '"></td>' ) . ' ';
|
187 |
+
$row_string .= ( $element['show_image'] ) ? '<td class="product-thumbnail">%2$s</td>' : '<td class="product-thumbnail"> </td>';
|
188 |
|
189 |
+
$row_string .= ( $element['show_title'] ) ? '<td class="product-name">%1$s</td>' : '<td class="product-name"> </td>';
|
190 |
|
191 |
+
if ( tinv_get_option( 'product_table', 'colm_price' ) ) {
|
192 |
+
$row_string .= ( $product_price && $element['show_price'] && $element['priced_individually'] ) ? '<td class="product-price">%4$s × %6$s</td>' : '<td class="product-price">× %6$s</td>';
|
193 |
}
|
194 |
+
if ( tinv_get_option( 'product_table', 'colm_date' ) ) {
|
195 |
$row_string .= '<td class="product-date"> </td>';
|
196 |
}
|
197 |
+
if ( tinv_get_option( 'product_table', 'colm_stock' ) ) {
|
198 |
$row_string .= '<td class="product-stock">%5$s</td>';
|
199 |
}
|
200 |
+
if ( tinv_get_option( 'product_table', 'colm_quantity' ) ) {
|
201 |
$row_string .= '<td class="product-quantity"> </td>';
|
202 |
}
|
203 |
+
if ( tinv_get_option( 'product_table', 'add_to_cart' ) ) {
|
204 |
$row_string .= '<td class="product-action"> </td>';
|
205 |
}
|
206 |
$row_string .= '</tr>';
|
207 |
|
208 |
+
echo sprintf( $row_string, is_callable( array(
|
209 |
$_product,
|
210 |
'get_name'
|
211 |
+
) ) ? $_product->get_name() : $_product->get_title(), $product_image, $product_title, $product_price, '', $wl_product['meta'][ $attribute . '_quantity' ] ); // WPCS: xss ok.
|
212 |
|
213 |
}
|
214 |
}
|
221 |
}
|
222 |
}
|
223 |
|
224 |
+
add_action( 'tinvwl_wishlist_row_after', 'tinvwl_row_woocommerce_tm_extra_product_options', 10, 2 );
|
225 |
} // End if().
|
226 |
|
227 |
+
if ( ! function_exists( 'tinvwl_item_price_woocommerce_tm_extra_product_options' ) ) {
|
228 |
|
229 |
/**
|
230 |
* Modify price for WooCommerce TM Extra Product Options
|
235 |
*
|
236 |
* @return string
|
237 |
*/
|
238 |
+
function tinvwl_item_price_woocommerce_tm_extra_product_options( $price, $wl_product, $product ) {
|
239 |
+
if ( array_key_exists( 'tcaddtocart', (array) @$wl_product['meta'] ) && ( defined( 'THEMECOMPLETE_EPO_VERSION' ) || defined( 'TM_EPO_VERSION' ) ) ) {
|
240 |
+
|
241 |
+
$api = defined( 'THEMECOMPLETE_EPO_VERSION' ) ? THEMECOMPLETE_EPO_API() : TM_EPO_API();
|
242 |
+
$core = defined( 'THEMECOMPLETE_EPO_VERSION' ) ? THEMECOMPLETE_EPO() : TM_EPO();
|
243 |
+
$version = defined( 'THEMECOMPLETE_EPO_VERSION' ) ? THEMECOMPLETE_EPO_VERSION : TM_EPO_VERSION;
|
244 |
+
$cart = defined( 'THEMECOMPLETE_EPO_VERSION' ) ? new THEMECOMPLETE_EPO_Cart() : TM_EPO();
|
245 |
+
|
246 |
+
// foreach ( $wl_product['meta'] as $key => $data ) {
|
247 |
+
// $data = ( is_object( json_decode( $data ) ) ) ? json_decode( $data, true ) : $data;
|
248 |
+
// $wl_product['meta'][ $key ] = is_array( $data ) ? array_shift( $data ) : $data;
|
249 |
+
// }
|
250 |
+
|
251 |
+
if ( $core->tm_epo_hide_options_in_cart == 'no' ) {
|
252 |
$product_id = $wl_product['product_id'];
|
253 |
+
$has_epo = $api->has_options( $product_id );
|
254 |
+
if ( $api->is_valid_options( $has_epo ) ) {
|
255 |
|
256 |
+
$cart_class = version_compare( $version, '4.8.0', '<' ) ? $core : $cart;
|
257 |
|
258 |
+
$cart_item = $cart_class->add_cart_item_data_helper( array(), $product_id, $wl_product['meta'] );
|
259 |
$cart_item['quantity'] = 1;
|
260 |
+
$cart_item['data'] = $product;
|
261 |
+
|
262 |
+
$product_price = apply_filters( 'wc_epo_add_cart_item_original_price', $cart_item['data']->get_price(), $cart_item );
|
263 |
+
if ( ! empty( $cart_item['tmcartepo'] ) ) {
|
264 |
+
$to_currency = version_compare( $version, '4.9.0', '<' ) ? tc_get_woocommerce_currency() : themecomplete_get_woocommerce_currency();
|
265 |
+
foreach ( $cart_item['tmcartepo'] as $value ) {
|
266 |
+
if ( isset( $value['price_per_currency'] ) && array_key_exists( $to_currency, $value['price_per_currency'] ) ) {
|
267 |
+
$value = floatval( $value['price_per_currency'][ $to_currency ] );
|
268 |
$product_price += $value;
|
269 |
} else {
|
270 |
+
$product_price += floatval( $value['price'] );
|
271 |
}
|
272 |
}
|
273 |
}
|
274 |
|
275 |
+
$price = apply_filters( 'wc_tm_epo_ac_product_price', apply_filters( 'woocommerce_cart_item_price', $cart_class->get_price_for_cart( $product_price, $cart_item, '' ), $cart_item, '' ), '', $cart_item, $product, $product_id );
|
276 |
}
|
277 |
}
|
278 |
}
|
280 |
return $price;
|
281 |
}
|
282 |
|
283 |
+
add_filter( 'tinvwl_wishlist_item_price', 'tinvwl_item_price_woocommerce_tm_extra_product_options', 10, 3 );
|
284 |
} // End if().
|
285 |
|
286 |
+
add_filter( 'tinvwl_addtowishlist_prepare_form', 'tinvwl_meta_woocommerce_tm_extra_product_options', 10, 3 );
|
287 |
|
288 |
+
function tinvwl_meta_woocommerce_tm_extra_product_options( $meta, $post, $files ) {
|
|
|
289 |
|
290 |
+
if ( defined( 'THEMECOMPLETE_EPO_VERSION' ) || defined( 'TM_EPO_VERSION' ) ) {
|
291 |
+
foreach ( $files as $name => $file ) {
|
292 |
|
293 |
+
if ( array_key_exists( $name, $meta ) ) {
|
294 |
+
$upload = THEMECOMPLETE_EPO()->upload_file( $file );
|
295 |
+
if ( empty( $upload['error'] ) && ! empty( $upload['file'] ) ) {
|
296 |
+
$meta[ $name ] = wc_clean( $upload['url'] );
|
297 |
}
|
298 |
}
|
299 |
}
|
300 |
}
|
301 |
|
302 |
+
foreach ( $meta as $key => $data ) {
|
303 |
+
$data = ( ! is_array( $data ) && is_object( json_decode( $data ) ) ) ? json_decode( $data, true ) : $data;
|
304 |
+
$meta[ $key ] = is_array( $data ) ? array_shift( $data ) : $data;
|
305 |
+
}
|
306 |
+
|
307 |
return $meta;
|
308 |
}
|
309 |
|
310 |
+
add_filter( 'tinvwl_product_prepare_meta', 'tinvwl_cart_meta_woocommerce_tm_extra_product_options' );
|
311 |
|
312 |
+
function tinvwl_cart_meta_woocommerce_tm_extra_product_options( $meta ) {
|
|
|
313 |
|
314 |
+
if ( defined( 'THEMECOMPLETE_EPO_VERSION' ) || defined( 'TM_EPO_VERSION' ) ) {
|
315 |
|
316 |
$files = $_FILES;
|
317 |
|
318 |
+
foreach ( $files as $name => $file ) {
|
319 |
|
320 |
+
if ( ! array_key_exists( $name, $meta ) ) {
|
321 |
+
$upload = THEMECOMPLETE_EPO()->upload_file( $file );
|
322 |
+
if ( empty( $upload['error'] ) && ! empty( $upload['file'] ) ) {
|
323 |
+
$meta[ $name ] = wc_clean( $upload['url'] );
|
324 |
}
|
325 |
}
|
326 |
}
|
327 |
}
|
328 |
|
329 |
+
foreach ( $meta as $key => $data ) {
|
330 |
+
$data = ( ! is_array( $data ) && is_object( json_decode( $data ) ) ) ? json_decode( $data, true ) : $data;
|
331 |
+
$meta[ $key ] = is_array( $data ) ? array_shift( $data ) : $data;
|
332 |
+
}
|
333 |
+
|
334 |
return $meta;
|
335 |
}
|
336 |
|
337 |
+
function tinvwl_add_to_wishlist_tm_extra_product_options() {
|
338 |
+
wp_add_inline_script( 'tinvwl', "
|
|
|
339 |
jQuery('body').on('tinvwl_add_to_wishlist_button_click', function(e, el){
|
340 |
jQuery(el).closest('form.cart').each(function(){
|
341 |
if (jQuery(this).find('#tm-extra-product-options').length) {
|
353 |
}
|
354 |
});
|
355 |
});
|
356 |
+
" );
|
357 |
}
|
358 |
|
359 |
+
add_action( 'wp_enqueue_scripts', 'tinvwl_add_to_wishlist_tm_extra_product_options', 100, 1 );
|
languages/ti-woocommerce-wishlist.pot
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
-
# Copyright (C) 2022 TI WooCommerce Wishlist Plugin - 2.0.
|
2 |
-
# This file is distributed under the same license as the TI WooCommerce Wishlist Plugin - 2.0.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
-
"Project-Id-Version: TI WooCommerce Wishlist Plugin - 2.0.
|
6 |
"MIME-Version: 1.0\n"
|
7 |
"Content-Type: text/plain; charset=UTF-8\n"
|
8 |
"Content-Transfer-Encoding: 8bit\n"
|
@@ -11,7 +11,7 @@ msgstr ""
|
|
11 |
"Language-Team: TemplateInvaders (https://templateinvaders.com/)\n"
|
12 |
"Last-Translator: TemplateInvaders (https://templateinvaders.com/)\n"
|
13 |
"MIME-Version: 1.0\n"
|
14 |
-
"Project-Id-Version: TI WooCommerce Wishlist Plugin - 2.0.
|
15 |
"Report-Msgid-Bugs-To: https://templateinvaders.com/help/\n"
|
16 |
"X-Poedit-Basepath: ..\n"
|
17 |
"X-Poedit-KeywordsList: __;_e;_ex:1,2c;_n:1,2;_n_noop:1,2;_nx:1,2,4c;_nx_noop:1,2,3c;_x:1,2c;esc_attr__;esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c\n"
|
@@ -1028,7 +1028,7 @@ msgstr ""
|
|
1028 |
msgid "Page Setup"
|
1029 |
msgstr ""
|
1030 |
|
1031 |
-
#: includes/wizard.class.php:317, includes/wizard.class.php:349, integrations/theme-flatsome.php:124, integrations/theme-flatsome.php:167, integrations/theme-flatsome.php:245, integrations/theme-flatsome.php:284, public/tinvwl.class.php:
|
1032 |
msgid "Wishlist"
|
1033 |
msgstr ""
|
1034 |
|
@@ -1256,23 +1256,23 @@ msgstr ""
|
|
1256 |
msgid "Login"
|
1257 |
msgstr ""
|
1258 |
|
1259 |
-
#: public/addtowishlist.class.php:213, public/wishlist/ajax.class.php:
|
1260 |
msgid "Something went wrong"
|
1261 |
msgstr ""
|
1262 |
|
1263 |
-
#: public/tinvwl.class.php:
|
1264 |
msgid "Create New"
|
1265 |
msgstr ""
|
1266 |
|
1267 |
-
#: public/tinvwl.class.php:
|
1268 |
msgid "Please select some product options before adding this product to your wishlist."
|
1269 |
msgstr ""
|
1270 |
|
1271 |
-
#: public/tinvwl.class.php:
|
1272 |
msgid "No items or actions are selected."
|
1273 |
msgstr ""
|
1274 |
|
1275 |
-
#: public/tinvwl.class.php:
|
1276 |
msgid "Copied!"
|
1277 |
msgstr ""
|
1278 |
|
@@ -1296,19 +1296,19 @@ msgstr ""
|
|
1296 |
msgid "Counter Text"
|
1297 |
msgstr ""
|
1298 |
|
1299 |
-
#: public/wishlist/ajax.class.php:
|
1300 |
msgid "“%s”"
|
1301 |
msgstr ""
|
1302 |
|
1303 |
-
#: public/wishlist/ajax.class.php:
|
1304 |
msgid "%s has not been removed from wishlist."
|
1305 |
msgstr ""
|
1306 |
|
1307 |
-
#: public/wishlist/ajax.class.php:
|
1308 |
msgid "%s has been removed from wishlist."
|
1309 |
msgstr ""
|
1310 |
|
1311 |
-
#: public/wishlist/ajax.class.php:
|
1312 |
msgid "%s has not been added to your cart."
|
1313 |
msgid_plural "%s have been added to your cart."
|
1314 |
msgstr[0] ""
|
@@ -1316,13 +1316,13 @@ msgstr[1] ""
|
|
1316 |
|
1317 |
#. translators: %s: product name
|
1318 |
#. translators: %s: product name
|
1319 |
-
#: public/wishlist/ajax.class.php:
|
1320 |
msgid "%s has been added to your cart."
|
1321 |
msgid_plural "%s have been added to your cart."
|
1322 |
msgstr[0] ""
|
1323 |
msgstr[1] ""
|
1324 |
|
1325 |
-
#: public/wishlist/ajax.class.php:
|
1326 |
msgid "%s has been successfully removed from wishlist."
|
1327 |
msgid_plural "%s have been successfully removed from wishlist."
|
1328 |
msgstr[0] ""
|
@@ -1330,12 +1330,12 @@ msgstr[1] ""
|
|
1330 |
|
1331 |
#. translators: %s: product name
|
1332 |
#. translators: %s: product name
|
1333 |
-
#: public/wishlist/ajax.class.php:
|
1334 |
msgctxt "Item name in quotes"
|
1335 |
msgid "“%s”"
|
1336 |
msgstr ""
|
1337 |
|
1338 |
-
#: public/wishlist/ajax.class.php:
|
1339 |
msgid "Product %s could not be added to the cart because some requirements are not met."
|
1340 |
msgid_plural "Products: %s could not be added to the cart because some requirements are not met."
|
1341 |
msgstr[0] ""
|
@@ -1349,11 +1349,11 @@ msgstr ""
|
|
1349 |
msgid "Action"
|
1350 |
msgstr ""
|
1351 |
|
1352 |
-
#: public/wishlist/buttons.class.php:
|
1353 |
msgid "Actions"
|
1354 |
msgstr ""
|
1355 |
|
1356 |
-
#: public/wishlist/buttons.class.php:
|
1357 |
msgid "Remove"
|
1358 |
msgstr ""
|
1359 |
|
1 |
+
# Copyright (C) 2022 TI WooCommerce Wishlist Plugin - 2.0.7
|
2 |
+
# This file is distributed under the same license as the TI WooCommerce Wishlist Plugin - 2.0.7 package.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
+
"Project-Id-Version: TI WooCommerce Wishlist Plugin - 2.0.7\n"
|
6 |
"MIME-Version: 1.0\n"
|
7 |
"Content-Type: text/plain; charset=UTF-8\n"
|
8 |
"Content-Transfer-Encoding: 8bit\n"
|
11 |
"Language-Team: TemplateInvaders (https://templateinvaders.com/)\n"
|
12 |
"Last-Translator: TemplateInvaders (https://templateinvaders.com/)\n"
|
13 |
"MIME-Version: 1.0\n"
|
14 |
+
"Project-Id-Version: TI WooCommerce Wishlist Plugin - 2.0.7\n"
|
15 |
"Report-Msgid-Bugs-To: https://templateinvaders.com/help/\n"
|
16 |
"X-Poedit-Basepath: ..\n"
|
17 |
"X-Poedit-KeywordsList: __;_e;_ex:1,2c;_n:1,2;_n_noop:1,2;_nx:1,2,4c;_nx_noop:1,2,3c;_x:1,2c;esc_attr__;esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c\n"
|
1028 |
msgid "Page Setup"
|
1029 |
msgstr ""
|
1030 |
|
1031 |
+
#: includes/wizard.class.php:317, includes/wizard.class.php:349, integrations/theme-flatsome.php:124, integrations/theme-flatsome.php:167, integrations/theme-flatsome.php:245, integrations/theme-flatsome.php:284, public/tinvwl.class.php:690, views/header.php:25
|
1032 |
msgid "Wishlist"
|
1033 |
msgstr ""
|
1034 |
|
1256 |
msgid "Login"
|
1257 |
msgstr ""
|
1258 |
|
1259 |
+
#: public/addtowishlist.class.php:213, public/wishlist/ajax.class.php:97, public/wishlist/ajax.class.php:123, public/wishlist/ajax.class.php:134, public/wishlist/ajax.class.php:141, public/wishlist/ajax.class.php:172, public/wishlist/ajax.class.php:179
|
1260 |
msgid "Something went wrong"
|
1261 |
msgstr ""
|
1262 |
|
1263 |
+
#: public/tinvwl.class.php:524
|
1264 |
msgid "Create New"
|
1265 |
msgstr ""
|
1266 |
|
1267 |
+
#: public/tinvwl.class.php:528
|
1268 |
msgid "Please select some product options before adding this product to your wishlist."
|
1269 |
msgstr ""
|
1270 |
|
1271 |
+
#: public/tinvwl.class.php:529
|
1272 |
msgid "No items or actions are selected."
|
1273 |
msgstr ""
|
1274 |
|
1275 |
+
#: public/tinvwl.class.php:530
|
1276 |
msgid "Copied!"
|
1277 |
msgstr ""
|
1278 |
|
1296 |
msgid "Counter Text"
|
1297 |
msgstr ""
|
1298 |
|
1299 |
+
#: public/wishlist/ajax.class.php:145, public/wishlist/ajax.class.php:183, public/wishlist/ajax.class.php:253
|
1300 |
msgid "“%s”"
|
1301 |
msgstr ""
|
1302 |
|
1303 |
+
#: public/wishlist/ajax.class.php:159
|
1304 |
msgid "%s has not been removed from wishlist."
|
1305 |
msgstr ""
|
1306 |
|
1307 |
+
#: public/wishlist/ajax.class.php:152
|
1308 |
msgid "%s has been removed from wishlist."
|
1309 |
msgstr ""
|
1310 |
|
1311 |
+
#: public/wishlist/ajax.class.php:221
|
1312 |
msgid "%s has not been added to your cart."
|
1313 |
msgid_plural "%s have been added to your cart."
|
1314 |
msgstr[0] ""
|
1316 |
|
1317 |
#. translators: %s: product name
|
1318 |
#. translators: %s: product name
|
1319 |
+
#: public/wishlist/ajax.class.php:210, public/wishlist/ajax.class.php:341, public/wishlist/ajax.class.php:423
|
1320 |
msgid "%s has been added to your cart."
|
1321 |
msgid_plural "%s have been added to your cart."
|
1322 |
msgstr[0] ""
|
1323 |
msgstr[1] ""
|
1324 |
|
1325 |
+
#: public/wishlist/ajax.class.php:261
|
1326 |
msgid "%s has been successfully removed from wishlist."
|
1327 |
msgid_plural "%s have been successfully removed from wishlist."
|
1328 |
msgstr[0] ""
|
1330 |
|
1331 |
#. translators: %s: product name
|
1332 |
#. translators: %s: product name
|
1333 |
+
#: public/wishlist/ajax.class.php:323, public/wishlist/ajax.class.php:335, public/wishlist/ajax.class.php:405, public/wishlist/ajax.class.php:417
|
1334 |
msgctxt "Item name in quotes"
|
1335 |
msgid "“%s”"
|
1336 |
msgstr ""
|
1337 |
|
1338 |
+
#: public/wishlist/ajax.class.php:326, public/wishlist/ajax.class.php:408
|
1339 |
msgid "Product %s could not be added to the cart because some requirements are not met."
|
1340 |
msgid_plural "Products: %s could not be added to the cart because some requirements are not met."
|
1341 |
msgstr[0] ""
|
1349 |
msgid "Action"
|
1350 |
msgstr ""
|
1351 |
|
1352 |
+
#: public/wishlist/buttons.class.php:228
|
1353 |
msgid "Actions"
|
1354 |
msgstr ""
|
1355 |
|
1356 |
+
#: public/wishlist/buttons.class.php:237, templates/ti-wishlist.php:93
|
1357 |
msgid "Remove"
|
1358 |
msgstr ""
|
1359 |
|
public/addtowishlist.class.php
CHANGED
@@ -372,7 +372,13 @@ class TInvWL_Public_AddToWishlist {
|
|
372 |
if ( tinv_get_option( 'general', 'simple_flow' ) ) {
|
373 |
$data['make_remove'] = $data['status'];
|
374 |
}
|
375 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
376 |
$data = apply_filters( 'tinvwl_addtowishlist_return_ajax', $data, $post, $form, $product );
|
377 |
ob_clean();
|
378 |
wp_send_json( $data );
|
@@ -424,6 +430,7 @@ class TInvWL_Public_AddToWishlist {
|
|
424 |
} else {
|
425 |
$default['field'] = $table . '.*, ';
|
426 |
}
|
|
|
427 |
$default['field'] .= $table_lists . '.ID as wishlist_id, ' . $table_lists . '.status as wishlist_status, ' . $table_lists . '.title as wishlist_title, ' . $table_lists . '.share_key as wishlist_share_key';
|
428 |
|
429 |
$sql = "SELECT {$default[ 'field' ]} FROM `{$table}` INNER JOIN `{$table_lists}` ON `{$table}`.`wishlist_id` = `{$table_lists}`.`ID` AND `{$table_lists}`.`type` = 'default'";
|
@@ -531,13 +538,16 @@ JOIN {$table_languages} l ON
|
|
531 |
}
|
532 |
}
|
533 |
}
|
|
|
534 |
}
|
535 |
|
536 |
if ( $stats ) {
|
537 |
$stats_sql = "SELECT `A`.`product_id`, `A`.`variation_id`, COUNT(`B`.`ID`) AS `count` FROM `{$table_stats}` AS `A` LEFT JOIN `{$table}` AS `C` ON `C`.`wishlist_id` = `A`.`wishlist_id` AND `C`.`product_id` = `A`.`product_id` AND `C`.`variation_id` = `A`.`variation_id` LEFT JOIN `{$table_lists}` AS `B` ON `C`.`wishlist_id` = `B`.`ID` LEFT JOIN `{$table_lists}` AS `G` ON `C`.`wishlist_id` = `G`.`ID` AND `G`.`author` = 0 WHERE `A`.`product_id` > 0 GROUP BY `A`.`product_id`, `A`.`variation_id` HAVING `count` > 0 LIMIT 0, 9999999";
|
538 |
|
539 |
$stats_results = $wpdb->get_results( $stats_sql, ARRAY_A );
|
|
|
540 |
if ( ! empty( $stats_results ) ) {
|
|
|
541 |
foreach ( $stats_results as $product_stats ) {
|
542 |
$analytics[ $product_stats['product_id'] ][ $product_stats['variation_id'] ] = $product_stats['count'];
|
543 |
}
|
372 |
if ( tinv_get_option( 'general', 'simple_flow' ) ) {
|
373 |
$data['make_remove'] = $data['status'];
|
374 |
}
|
375 |
+
$share_key = false;
|
376 |
+
|
377 |
+
if ( ! is_user_logged_in() ) {
|
378 |
+
$share_key = $wishlist['share_key'];
|
379 |
+
}
|
380 |
+
|
381 |
+
$data['wishlists_data'] = $this->get_wishlists_data( $share_key );
|
382 |
$data = apply_filters( 'tinvwl_addtowishlist_return_ajax', $data, $post, $form, $product );
|
383 |
ob_clean();
|
384 |
wp_send_json( $data );
|
430 |
} else {
|
431 |
$default['field'] = $table . '.*, ';
|
432 |
}
|
433 |
+
|
434 |
$default['field'] .= $table_lists . '.ID as wishlist_id, ' . $table_lists . '.status as wishlist_status, ' . $table_lists . '.title as wishlist_title, ' . $table_lists . '.share_key as wishlist_share_key';
|
435 |
|
436 |
$sql = "SELECT {$default[ 'field' ]} FROM `{$table}` INNER JOIN `{$table_lists}` ON `{$table}`.`wishlist_id` = `{$table_lists}`.`ID` AND `{$table_lists}`.`type` = 'default'";
|
538 |
}
|
539 |
}
|
540 |
}
|
541 |
+
|
542 |
}
|
543 |
|
544 |
if ( $stats ) {
|
545 |
$stats_sql = "SELECT `A`.`product_id`, `A`.`variation_id`, COUNT(`B`.`ID`) AS `count` FROM `{$table_stats}` AS `A` LEFT JOIN `{$table}` AS `C` ON `C`.`wishlist_id` = `A`.`wishlist_id` AND `C`.`product_id` = `A`.`product_id` AND `C`.`variation_id` = `A`.`variation_id` LEFT JOIN `{$table_lists}` AS `B` ON `C`.`wishlist_id` = `B`.`ID` LEFT JOIN `{$table_lists}` AS `G` ON `C`.`wishlist_id` = `G`.`ID` AND `G`.`author` = 0 WHERE `A`.`product_id` > 0 GROUP BY `A`.`product_id`, `A`.`variation_id` HAVING `count` > 0 LIMIT 0, 9999999";
|
546 |
|
547 |
$stats_results = $wpdb->get_results( $stats_sql, ARRAY_A );
|
548 |
+
|
549 |
if ( ! empty( $stats_results ) ) {
|
550 |
+
$analytics = array();
|
551 |
foreach ( $stats_results as $product_stats ) {
|
552 |
$analytics[ $product_stats['product_id'] ][ $product_stats['variation_id'] ] = $product_stats['count'];
|
553 |
}
|
public/tinvwl.class.php
CHANGED
@@ -82,8 +82,6 @@ class TInvWL_Public_TInvWL {
|
|
82 |
|
83 |
add_filter( 'rewrite_rules_array', array( $this, 'add_rewrite_rules_raw' ), 9999999 );
|
84 |
|
85 |
-
add_filter( 'tinvwl_update_wishlists_data', array( $this, 'update_local_wishlists_data' ) );
|
86 |
-
|
87 |
add_filter( 'query_vars', array( $this, 'add_query_var' ) );
|
88 |
add_action( 'wp', array( $this, 'analytics_referer' ) );
|
89 |
add_action( 'deleted_user', array( $this, 'delete_user_wishlist' ) );
|
@@ -102,16 +100,6 @@ class TInvWL_Public_TInvWL {
|
|
102 |
$this->topwishlist = TInvWL_Public_WishlistCounter::instance( $this->_name );
|
103 |
}
|
104 |
|
105 |
-
function update_local_wishlists_data( $state ) {
|
106 |
-
if ( get_transient( '_tinvwl_update_wishlists_data' ) ) {
|
107 |
-
delete_transient( '_tinvwl_update_wishlists_data' );
|
108 |
-
|
109 |
-
return true;
|
110 |
-
}
|
111 |
-
|
112 |
-
return $state;
|
113 |
-
}
|
114 |
-
|
115 |
/**
|
116 |
* @param $rules
|
117 |
*
|
@@ -260,6 +248,10 @@ class TInvWL_Public_TInvWL {
|
|
260 |
* Create rewrite url for wishlist
|
261 |
*/
|
262 |
public static function add_rewrite_rules() {
|
|
|
|
|
|
|
|
|
263 |
$id = tinv_get_option( 'page', 'wishlist' );
|
264 |
$pages = array( $id );
|
265 |
$language_codes = array();
|
82 |
|
83 |
add_filter( 'rewrite_rules_array', array( $this, 'add_rewrite_rules_raw' ), 9999999 );
|
84 |
|
|
|
|
|
85 |
add_filter( 'query_vars', array( $this, 'add_query_var' ) );
|
86 |
add_action( 'wp', array( $this, 'analytics_referer' ) );
|
87 |
add_action( 'deleted_user', array( $this, 'delete_user_wishlist' ) );
|
100 |
$this->topwishlist = TInvWL_Public_WishlistCounter::instance( $this->_name );
|
101 |
}
|
102 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
/**
|
104 |
* @param $rules
|
105 |
*
|
248 |
* Create rewrite url for wishlist
|
249 |
*/
|
250 |
public static function add_rewrite_rules() {
|
251 |
+
if ( tinv_get_option( 'general', 'my_account_endpoint' ) ) {
|
252 |
+
return;
|
253 |
+
}
|
254 |
+
|
255 |
$id = tinv_get_option( 'page', 'wishlist' );
|
256 |
$pages = array( $id );
|
257 |
$language_codes = array();
|
public/wishlist/ajax.class.php
CHANGED
@@ -79,8 +79,19 @@ class TInvWL_Public_Wishlist_Ajax {
|
|
79 |
$wl = new TInvWL_Wishlist( $this->_name );
|
80 |
$wishlist = $wl->get_by_share_key( $post['tinvwl-sharekey'] );
|
81 |
|
82 |
-
if (
|
83 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
} else {
|
85 |
$response['status'] = false;
|
86 |
$response['msg'][] = __( 'Something went wrong', 'ti-woocommerce-wishlist' );
|
@@ -97,11 +108,11 @@ class TInvWL_Public_Wishlist_Ajax {
|
|
97 |
}
|
98 |
}
|
99 |
|
100 |
-
function wishlist_ajax_actions( $wishlist, $post ) {
|
101 |
$post['wishlist_qty'] = 1;
|
102 |
$action = $post['tinvwl-action'];
|
103 |
$class = TInvWL_Public_AddToWishlist::instance();
|
104 |
-
$owner = (bool) $wishlist['is_owner'];
|
105 |
$response['status'] = false;
|
106 |
$response['msg'] = array();
|
107 |
|
@@ -143,9 +154,6 @@ class TInvWL_Public_Wishlist_Ajax {
|
|
143 |
'paged' => $post['tinvwl-paged'],
|
144 |
'sharekey' => $post['tinvwl-sharekey']
|
145 |
) );
|
146 |
-
if ( $owner ) {
|
147 |
-
$response['wishlists_data'] = $class->get_wishlists_data( $wishlist['share_key'] );
|
148 |
-
}
|
149 |
} else {
|
150 |
$response['status'] = false;
|
151 |
$response['msg'][] = sprintf( __( '%s has not been removed from wishlist.', 'ti-woocommerce-wishlist' ), $title );
|
@@ -208,12 +216,6 @@ class TInvWL_Public_Wishlist_Ajax {
|
|
208 |
if ( 'yes' === get_option( 'woocommerce_cart_redirect_after_add' ) ) {
|
209 |
$response['redirect'] = wc_get_cart_url();
|
210 |
}
|
211 |
-
|
212 |
-
if ( tinv_get_option( 'processing', 'autoremove' ) ) {
|
213 |
-
if ( $owner ) {
|
214 |
-
$response['wishlists_data'] = $class->get_wishlists_data( $wishlist['share_key'] );
|
215 |
-
}
|
216 |
-
}
|
217 |
} else {
|
218 |
$response['status'] = false;
|
219 |
$response['msg'][] = sprintf( _n( '%s has not been added to your cart.', '%s have been added to your cart.', 1, 'ti-woocommerce-wishlist' ), $title );
|
@@ -255,13 +257,12 @@ class TInvWL_Public_Wishlist_Ajax {
|
|
255 |
}
|
256 |
}
|
257 |
if ( ! empty( $titles ) ) {
|
258 |
-
$response['status']
|
259 |
-
$response['msg'][]
|
260 |
-
$response['content']
|
261 |
'paged' => $post['tinvwl-paged'],
|
262 |
'sharekey' => $post['tinvwl-sharekey']
|
263 |
) );
|
264 |
-
$response['wishlists_data'] = $class->get_wishlists_data( $wishlist['share_key'] );
|
265 |
}
|
266 |
|
267 |
break;
|
@@ -346,12 +347,6 @@ class TInvWL_Public_Wishlist_Ajax {
|
|
346 |
if ( 'yes' === get_option( 'woocommerce_cart_redirect_after_add' ) ) {
|
347 |
$response['redirect'] = wc_get_cart_url();
|
348 |
}
|
349 |
-
|
350 |
-
if ( tinv_get_option( 'processing', 'autoremove' ) ) {
|
351 |
-
if ( $owner ) {
|
352 |
-
$response['wishlists_data'] = $class->get_wishlists_data( $wishlist['share_key'] );
|
353 |
-
}
|
354 |
-
}
|
355 |
}
|
356 |
$response['content'] = tinvwl_shortcode_view( array(
|
357 |
'paged' => $post['tinvwl-paged'],
|
@@ -434,18 +429,15 @@ class TInvWL_Public_Wishlist_Ajax {
|
|
434 |
if ( 'yes' === get_option( 'woocommerce_cart_redirect_after_add' ) ) {
|
435 |
$response['redirect'] = wc_get_cart_url();
|
436 |
}
|
437 |
-
|
438 |
-
if ( tinv_get_option( 'processing', 'autoremove' ) ) {
|
439 |
-
if ( $owner ) {
|
440 |
-
$response['wishlists_data'] = $class->get_wishlists_data( $wishlist['share_key'] );
|
441 |
-
}
|
442 |
-
}
|
443 |
}
|
444 |
$response['content'] = tinvwl_shortcode_view( array(
|
445 |
'paged' => $post['tinvwl-paged'],
|
446 |
'sharekey' => $post['tinvwl-sharekey']
|
447 |
) );
|
448 |
break;
|
|
|
|
|
|
|
449 |
}
|
450 |
$response['icon'] = $response['status'] ? 'icon_big_heart_check' : 'icon_big_times';
|
451 |
$response['msg'] = array_unique( $response['msg'] );
|
@@ -457,6 +449,13 @@ class TInvWL_Public_Wishlist_Ajax {
|
|
457 |
$response['msg'] = tinv_wishlist_template_html( 'ti-addedtowishlist-dialogbox.php', apply_filters( 'tinvwl_addtowishlist_dialog_box', $response, $post ) );
|
458 |
}
|
459 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
460 |
do_action( 'tinvwl_action_' . $action, $wishlist, $post['tinvwl-products'], $post['wishlist_qty'], $owner ); // @codingStandardsIgnoreLine WordPress.NamingConventions.ValidHookName.UseUnderscores
|
461 |
|
462 |
wp_send_json( $response );
|
79 |
$wl = new TInvWL_Wishlist( $this->_name );
|
80 |
$wishlist = $wl->get_by_share_key( $post['tinvwl-sharekey'] );
|
81 |
|
82 |
+
if ( ! $wishlist ) {
|
83 |
+
$wishlist = $wl->get_by_user_default();
|
84 |
+
$wishlist = array_shift( $wishlist );
|
85 |
+
}
|
86 |
+
|
87 |
+
$guest_wishlist = false;
|
88 |
+
if ( ! is_user_logged_in() ) {
|
89 |
+
$guest_wishlist = $wl->get_by_user_default();
|
90 |
+
$guest_wishlist = array_shift( $guest_wishlist );
|
91 |
+
}
|
92 |
+
|
93 |
+
if ( defined( 'DOING_AJAX' ) && DOING_AJAX && $post['tinvwl-security'] && wp_verify_nonce( $post['tinvwl-security'], 'wp_rest' ) && $post['tinvwl-action'] ) {
|
94 |
+
$this->wishlist_ajax_actions( $wishlist, $post, $guest_wishlist );
|
95 |
} else {
|
96 |
$response['status'] = false;
|
97 |
$response['msg'][] = __( 'Something went wrong', 'ti-woocommerce-wishlist' );
|
108 |
}
|
109 |
}
|
110 |
|
111 |
+
function wishlist_ajax_actions( $wishlist, $post, $guest_wishlist = false ) {
|
112 |
$post['wishlist_qty'] = 1;
|
113 |
$action = $post['tinvwl-action'];
|
114 |
$class = TInvWL_Public_AddToWishlist::instance();
|
115 |
+
$owner = ( $wishlist && isset( $wishlist['is_owner'] ) ) ? (bool) $wishlist['is_owner'] : false;
|
116 |
$response['status'] = false;
|
117 |
$response['msg'] = array();
|
118 |
|
154 |
'paged' => $post['tinvwl-paged'],
|
155 |
'sharekey' => $post['tinvwl-sharekey']
|
156 |
) );
|
|
|
|
|
|
|
157 |
} else {
|
158 |
$response['status'] = false;
|
159 |
$response['msg'][] = sprintf( __( '%s has not been removed from wishlist.', 'ti-woocommerce-wishlist' ), $title );
|
216 |
if ( 'yes' === get_option( 'woocommerce_cart_redirect_after_add' ) ) {
|
217 |
$response['redirect'] = wc_get_cart_url();
|
218 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
219 |
} else {
|
220 |
$response['status'] = false;
|
221 |
$response['msg'][] = sprintf( _n( '%s has not been added to your cart.', '%s have been added to your cart.', 1, 'ti-woocommerce-wishlist' ), $title );
|
257 |
}
|
258 |
}
|
259 |
if ( ! empty( $titles ) ) {
|
260 |
+
$response['status'] = true;
|
261 |
+
$response['msg'][] = sprintf( _n( '%s has been successfully removed from wishlist.', '%s have been successfully removed from wishlist.', count( $titles ), 'ti-woocommerce-wishlist' ), wc_format_list_of_items( $titles ) );
|
262 |
+
$response['content'] = tinvwl_shortcode_view( array(
|
263 |
'paged' => $post['tinvwl-paged'],
|
264 |
'sharekey' => $post['tinvwl-sharekey']
|
265 |
) );
|
|
|
266 |
}
|
267 |
|
268 |
break;
|
347 |
if ( 'yes' === get_option( 'woocommerce_cart_redirect_after_add' ) ) {
|
348 |
$response['redirect'] = wc_get_cart_url();
|
349 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
350 |
}
|
351 |
$response['content'] = tinvwl_shortcode_view( array(
|
352 |
'paged' => $post['tinvwl-paged'],
|
429 |
if ( 'yes' === get_option( 'woocommerce_cart_redirect_after_add' ) ) {
|
430 |
$response['redirect'] = wc_get_cart_url();
|
431 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
432 |
}
|
433 |
$response['content'] = tinvwl_shortcode_view( array(
|
434 |
'paged' => $post['tinvwl-paged'],
|
435 |
'sharekey' => $post['tinvwl-sharekey']
|
436 |
) );
|
437 |
break;
|
438 |
+
case 'get_data':
|
439 |
+
$response['status'] = true;
|
440 |
+
break;
|
441 |
}
|
442 |
$response['icon'] = $response['status'] ? 'icon_big_heart_check' : 'icon_big_times';
|
443 |
$response['msg'] = array_unique( $response['msg'] );
|
449 |
$response['msg'] = tinv_wishlist_template_html( 'ti-addedtowishlist-dialogbox.php', apply_filters( 'tinvwl_addtowishlist_dialog_box', $response, $post ) );
|
450 |
}
|
451 |
|
452 |
+
$share_key = false;
|
453 |
+
|
454 |
+
if ( $guest_wishlist ) {
|
455 |
+
$share_key = $guest_wishlist['share_key'];
|
456 |
+
}
|
457 |
+
$response['wishlists_data'] = $class->get_wishlists_data( $share_key );
|
458 |
+
|
459 |
do_action( 'tinvwl_action_' . $action, $wishlist, $post['tinvwl-products'], $post['wishlist_qty'], $owner ); // @codingStandardsIgnoreLine WordPress.NamingConventions.ValidHookName.UseUnderscores
|
460 |
|
461 |
wp_send_json( $response );
|
public/wishlist/buttons.class.php
CHANGED
@@ -140,6 +140,7 @@ class TInvWL_Public_Wishlist_Buttons {
|
|
140 |
self::button( $button['name'], __( $button['title'] ), $button['submit'] );
|
141 |
}
|
142 |
}, $button['priority'] );
|
|
|
143 |
add_action( 'tinvwl_action_' . $button['name'], $button['method'], 10, 4 );
|
144 |
}
|
145 |
|
@@ -264,12 +265,12 @@ class TInvWL_Public_Wishlist_Buttons {
|
|
264 |
$paged = 1 < $paged ? $paged : 1;
|
265 |
|
266 |
if ( ! $per_page ) {
|
267 |
-
$per_page = apply_filters( 'tinvwl_wishlist_products_per_page', filter_input( INPUT_POST, 'lists_per_page', FILTER_VALIDATE_INT, array(
|
268 |
'options' => array(
|
269 |
'default' => 10,
|
270 |
'min_range' => 1,
|
271 |
),
|
272 |
-
) ) );
|
273 |
|
274 |
}
|
275 |
|
140 |
self::button( $button['name'], __( $button['title'] ), $button['submit'] );
|
141 |
}
|
142 |
}, $button['priority'] );
|
143 |
+
|
144 |
add_action( 'tinvwl_action_' . $button['name'], $button['method'], 10, 4 );
|
145 |
}
|
146 |
|
265 |
$paged = 1 < $paged ? $paged : 1;
|
266 |
|
267 |
if ( ! $per_page ) {
|
268 |
+
$per_page = absint( apply_filters( 'tinvwl_wishlist_products_per_page', filter_input( INPUT_POST, 'lists_per_page', FILTER_VALIDATE_INT, array(
|
269 |
'options' => array(
|
270 |
'default' => 10,
|
271 |
'min_range' => 1,
|
272 |
),
|
273 |
+
) ) ) );
|
274 |
|
275 |
}
|
276 |
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: templateinvaders
|
|
3 |
Tags: woocommerce, wishlist, woocommerce wishlist, e-commerce, ecommerce
|
4 |
Requires at least: 4.7
|
5 |
Tested up to: 6.0
|
6 |
-
Stable tag: 2.0.
|
7 |
License: GPLv3
|
8 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
9 |
Plugin URI: https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
@@ -163,6 +163,14 @@ Yes, you can! Join in on our [GitHub repository](https://github.com/TemplateInva
|
|
163 |
|
164 |
|
165 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
166 |
= 2.0.6 =
|
167 |
*Release Date - 5 October 2022*
|
168 |
|
3 |
Tags: woocommerce, wishlist, woocommerce wishlist, e-commerce, ecommerce
|
4 |
Requires at least: 4.7
|
5 |
Tested up to: 6.0
|
6 |
+
Stable tag: 2.0.7
|
7 |
License: GPLv3
|
8 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
9 |
Plugin URI: https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
163 |
|
164 |
|
165 |
== Changelog ==
|
166 |
+
= 2.0.7 =
|
167 |
+
*Release Date - 18 October 2022*
|
168 |
+
|
169 |
+
* WooCommerce 7.0 support
|
170 |
+
* Updated integration with the WooCommerce TM Extra Product Options plugin
|
171 |
+
* Improved frontend AJAX routine
|
172 |
+
* Fixed URL rewrites issue
|
173 |
+
|
174 |
= 2.0.6 =
|
175 |
*Release Date - 5 October 2022*
|
176 |
|
templates/ti-wishlist-empty.php
CHANGED
@@ -8,28 +8,28 @@
|
|
8 |
* @package TInvWishlist\Template
|
9 |
*/
|
10 |
|
11 |
-
if (!defined('ABSPATH')) {
|
12 |
exit; // Exit if accessed directly.
|
13 |
}
|
14 |
|
15 |
?>
|
16 |
<div class="tinv-wishlist woocommerce">
|
17 |
-
<?php do_action('tinvwl_before_wishlist', $wishlist); ?>
|
18 |
<?php if ( function_exists( 'wc_print_notices' ) && isset( WC()->session ) ) {
|
19 |
wc_print_notices();
|
20 |
} ?>
|
21 |
<p class="cart-empty woocommerce-info">
|
22 |
-
<?php if (get_current_user_id() === $wishlist['author']) { ?>
|
23 |
-
<?php esc_html_e('Your Wishlist is currently empty.', 'ti-woocommerce-wishlist'); ?>
|
24 |
<?php } else { ?>
|
25 |
-
<?php esc_html_e('Wishlist is currently empty.', 'ti-woocommerce-wishlist'); ?>
|
26 |
<?php } ?>
|
27 |
</p>
|
28 |
|
29 |
-
<?php do_action('tinvwl_wishlist_is_empty'); ?>
|
30 |
|
31 |
<p class="return-to-shop">
|
32 |
<a class="button wc-backward"
|
33 |
-
href="<?php echo esc_url(apply_filters('woocommerce_return_to_shop_redirect', wc_get_page_permalink('shop'))); ?>"><?php echo esc_html(apply_filters('woocommerce_return_to_shop_text', __('Return To Shop', 'ti-woocommerce-wishlist'))); ?></a>
|
34 |
</p>
|
35 |
</div>
|
8 |
* @package TInvWishlist\Template
|
9 |
*/
|
10 |
|
11 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
12 |
exit; // Exit if accessed directly.
|
13 |
}
|
14 |
|
15 |
?>
|
16 |
<div class="tinv-wishlist woocommerce">
|
17 |
+
<?php do_action( 'tinvwl_before_wishlist', $wishlist ); ?>
|
18 |
<?php if ( function_exists( 'wc_print_notices' ) && isset( WC()->session ) ) {
|
19 |
wc_print_notices();
|
20 |
} ?>
|
21 |
<p class="cart-empty woocommerce-info">
|
22 |
+
<?php if ( get_current_user_id() === $wishlist['author'] ) { ?>
|
23 |
+
<?php esc_html_e( 'Your Wishlist is currently empty.', 'ti-woocommerce-wishlist' ); ?>
|
24 |
<?php } else { ?>
|
25 |
+
<?php esc_html_e( 'Wishlist is currently empty.', 'ti-woocommerce-wishlist' ); ?>
|
26 |
<?php } ?>
|
27 |
</p>
|
28 |
|
29 |
+
<?php do_action( 'tinvwl_wishlist_is_empty' ); ?>
|
30 |
|
31 |
<p class="return-to-shop">
|
32 |
<a class="button wc-backward"
|
33 |
+
href="<?php echo esc_url( apply_filters( 'woocommerce_return_to_shop_redirect', wc_get_page_permalink( 'shop' ) ) ); ?>"><?php echo esc_html( apply_filters( 'woocommerce_return_to_shop_text', __( 'Return To Shop', 'ti-woocommerce-wishlist' ) ) ); ?></a>
|
34 |
</p>
|
35 |
</div>
|
ti-woocommerce-wishlist.php
CHANGED
@@ -4,11 +4,11 @@
|
|
4 |
* Plugin Name: TI WooCommerce Wishlist
|
5 |
* Plugin URI: https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
6 |
* Description: Wishlist functionality for your WooCommerce store.
|
7 |
-
* Version: 2.0.
|
8 |
* Requires at least: 4.7
|
9 |
* Tested up to: 6.0
|
10 |
* WC requires at least: 3.0
|
11 |
-
* WC tested up to:
|
12 |
* Author: TemplateInvaders
|
13 |
* Author URI: https://templateinvaders.com/
|
14 |
* License: GPL-2.0+
|
@@ -41,7 +41,7 @@ if ( ! defined( 'TINVWL_DOMAIN' ) ) {
|
|
41 |
}
|
42 |
|
43 |
if ( ! defined( 'TINVWL_FVERSION' ) ) {
|
44 |
-
define( 'TINVWL_FVERSION', '2.0.
|
45 |
}
|
46 |
|
47 |
if ( ! defined( 'TINVWL_LOAD_FREE' ) ) {
|
4 |
* Plugin Name: TI WooCommerce Wishlist
|
5 |
* Plugin URI: https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
6 |
* Description: Wishlist functionality for your WooCommerce store.
|
7 |
+
* Version: 2.0.7
|
8 |
* Requires at least: 4.7
|
9 |
* Tested up to: 6.0
|
10 |
* WC requires at least: 3.0
|
11 |
+
* WC tested up to: 7.0
|
12 |
* Author: TemplateInvaders
|
13 |
* Author URI: https://templateinvaders.com/
|
14 |
* License: GPL-2.0+
|
41 |
}
|
42 |
|
43 |
if ( ! defined( 'TINVWL_FVERSION' ) ) {
|
44 |
+
define( 'TINVWL_FVERSION', '2.0.7' );
|
45 |
}
|
46 |
|
47 |
if ( ! defined( 'TINVWL_LOAD_FREE' ) ) {
|
tinv-wishlists-function.php
CHANGED
@@ -498,7 +498,7 @@ if ( ! function_exists( 'tinv_url_wishlist' ) ) {
|
|
498 |
$share_key = $id;
|
499 |
if ( ! ( is_string( $id ) && preg_match( '/^[A-Fa-f0-9]{6}$/', $id ) ) ) {
|
500 |
$wishlist = tinv_wishlist_get( $id, false );
|
501 |
-
$share_key = $wishlist['share_key'];
|
502 |
}
|
503 |
|
504 |
return tinv_url_wishlist_by_key( $share_key, $paged );
|
498 |
$share_key = $id;
|
499 |
if ( ! ( is_string( $id ) && preg_match( '/^[A-Fa-f0-9]{6}$/', $id ) ) ) {
|
500 |
$wishlist = tinv_wishlist_get( $id, false );
|
501 |
+
$share_key = isset( $wishlist['share_key'] ) ? $wishlist['share_key'] : '';
|
502 |
}
|
503 |
|
504 |
return tinv_url_wishlist_by_key( $share_key, $paged );
|