File tree 3 files changed +47
-23
lines changed
app/code/Magento/Catalog/view/frontend 3 files changed +47
-23
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,8 @@ var config = {
17
17
priceOptionFile : 'Magento_Catalog/js/price-option-file' ,
18
18
priceOptions : 'Magento_Catalog/js/price-options' ,
19
19
priceUtils : 'Magento_Catalog/js/price-utils' ,
20
- catalogAddToCart : 'Magento_Catalog/js/catalog-add-to-cart'
20
+ catalogAddToCart : 'Magento_Catalog/js/catalog-add-to-cart' ,
21
+ productValidate : 'Magento_Catalog/js/validate-product'
21
22
}
22
23
}
23
24
} ;
Original file line number Diff line number Diff line change 51
51
}
52
52
</script>
53
53
<?php else : ?>
54
- <script>
55
- require([
56
- 'jquery',
57
- 'mage/mage',
58
- 'Magento_Catalog/product/view/validation',
59
- 'Magento_Catalog/js/catalog-add-to-cart'
60
- ], function ($) {
61
- 'use strict';
62
-
63
- $('#product_addtocart_form').mage('validation', {
64
- radioCheckboxClosest: '.nested',
65
- submitHandler: function (form) {
66
- var widget = $(form).catalogAddToCart({
67
- bindSubmit: false
68
- });
69
-
70
- widget.catalogAddToCart('submitForm', $(form));
71
-
72
- return false;
73
- }
74
- });
75
- });
54
+ <script type="text/x-magento-init">
55
+ {
56
+ "#product_addtocart_form": {
57
+ "productValidate": {}
58
+ }
59
+ }
76
60
</script>
77
61
<?php endif ; ?>
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Copyright © 2016 Magento. All rights reserved.
3
+ * See COPYING.txt for license details.
4
+ */
5
+ define ( [
6
+ 'jquery' ,
7
+ 'mage/mage' ,
8
+ 'Magento_Catalog/product/view/validation' ,
9
+ 'catalogAddToCart'
10
+ ] , function ( $ ) {
11
+ "use strict" ;
12
+
13
+ $ . widget ( 'mage.productValidate' , {
14
+
15
+ options : {
16
+ bindSubmit : false ,
17
+ radioCheckboxClosest : '.nested'
18
+ } ,
19
+
20
+ _create : function ( ) {
21
+ var self = this ;
22
+
23
+ this . element . mage ( 'validation' , {
24
+ radioCheckboxClosest : this . options . radioCheckboxClosest ,
25
+
26
+ submitHandler : function ( form ) {
27
+ var widget = $ ( form ) . catalogAddToCart ( {
28
+ bindSubmit : self . options . bindSubmit
29
+ } ) ;
30
+
31
+ widget . catalogAddToCart ( 'submitForm' , $ ( form ) ) ;
32
+ return false ;
33
+ }
34
+ } ) ;
35
+ }
36
+ } ) ;
37
+
38
+ return $ . mage . productValidate ;
39
+ } ) ;
You can’t perform that action at this time.
0 commit comments