@@ -16,7 +16,8 @@ define([
16
16
groupedInfo : '#super-product-table input' ,
17
17
downloadableInfo : '#downloadable-links-list input' ,
18
18
customOptionsInfo : '.product-custom-option' ,
19
- qtyInfo : '#qty'
19
+ qtyInfo : '#qty' ,
20
+ actionElement : '[data-action="add-to-wishlist"]'
20
21
} ,
21
22
22
23
/** @inheritdoc */
@@ -30,8 +31,10 @@ define([
30
31
_bind : function ( ) {
31
32
var options = this . options ,
32
33
dataUpdateFunc = '_updateWishlistData' ,
34
+ validateProductQty = '_validateWishlistQty' ,
33
35
changeCustomOption = 'change ' + options . customOptionsInfo ,
34
36
changeQty = 'change ' + options . qtyInfo ,
37
+ updateWishlist = 'click ' + options . actionElement ,
35
38
events = { } ,
36
39
key ;
37
40
@@ -45,6 +48,7 @@ define([
45
48
46
49
events [ changeCustomOption ] = dataUpdateFunc ;
47
50
events [ changeQty ] = dataUpdateFunc ;
51
+ events [ updateWishlist ] = validateProductQty ;
48
52
49
53
for ( key in options . productType ) {
50
54
if ( options . productType . hasOwnProperty ( key ) && options . productType [ key ] + 'Info' in options ) {
@@ -220,7 +224,24 @@ define([
220
224
221
225
$ ( form ) . attr ( 'action' , action ) . submit ( ) ;
222
226
} ) ;
223
- }
227
+ } ,
228
+
229
+ /**
230
+ * Validate product quantity before updating Wish List
231
+ *
232
+ * @param {jQuery.Event } event
233
+ * @private
234
+ */
235
+ _validateWishlistQty : function ( event ) {
236
+ var element = $ ( this . options . qtyInfo ) ;
237
+
238
+ if ( ! ( element . validation ( ) && element . validation ( 'isValid' ) ) ) {
239
+ event . preventDefault ( ) ;
240
+ event . stopPropagation ( ) ;
241
+ return ;
242
+ }
243
+ } ,
244
+
224
245
} ) ;
225
246
226
247
return $ . mage . addToWishlist ;
0 commit comments