File tree Expand file tree Collapse file tree 2 files changed +51
-2
lines changed
app/code/Magento/Catalog/view/frontend Expand file tree Collapse file tree 2 files changed +51
-2
lines changed Original file line number Diff line number Diff line change 40
40
</div>
41
41
</div>
42
42
<?php endif ; ?>
43
+ <?php if ($ block ->isRedirectToCartEnabled ()) : ?>
43
44
<script type="text/x-magento-init">
44
45
{
45
46
"#product_addtocart_form": {
49
50
}
50
51
}
51
52
</script>
52
- <?php if (! $ block -> isRedirectToCartEnabled ()) : ?>
53
+ <?php else : ?>
53
54
<script type="text/x-magento-init">
54
55
{
55
56
"#product_addtocart_form": {
56
- "catalogAddToCart ": {}
57
+ "Magento_Catalog/js/validate-product ": {}
57
58
}
58
59
}
59
60
</script>
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
+ options : {
15
+ bindSubmit : false ,
16
+ radioCheckboxClosest : '.nested'
17
+ } ,
18
+
19
+ /**
20
+ * Uses Magento's validation widget for the form object.
21
+ * @private
22
+ */
23
+ _create : function ( ) {
24
+ var bindSubmit = this . options . bindSubmit ;
25
+
26
+ this . element . validation ( {
27
+ radioCheckboxClosest : this . options . radioCheckboxClosest ,
28
+
29
+ /**
30
+ * Uses catalogAddToCart widget as submit handler.
31
+ * @param {Object } form
32
+ * @returns {Boolean }
33
+ */
34
+ submitHandler : function ( form ) {
35
+ var jqForm = $ ( form ) . catalogAddToCart ( {
36
+ bindSubmit : bindSubmit
37
+ } ) ;
38
+
39
+ jqForm . catalogAddToCart ( 'submitForm' , jqForm ) ;
40
+
41
+ return false ;
42
+ }
43
+ } ) ;
44
+ }
45
+ } ) ;
46
+
47
+ return $ . mage . productValidate ;
48
+ } ) ;
You can’t perform that action at this time.
0 commit comments