Skip to content

Commit e7dc3ce

Browse files
author
Karpenko, Oleksandr
committed
Merge branch 'MAGETWO-54186' of github.com:magento-frontend/magento2ce into PR
Conflicts: app/code/Magento/Catalog/view/frontend/templates/product/view/addtocart.phtml
2 parents b6750ea + 35594f4 commit e7dc3ce

File tree

2 files changed

+51
-2
lines changed

2 files changed

+51
-2
lines changed

app/code/Magento/Catalog/view/frontend/templates/product/view/addtocart.phtml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
</div>
4141
</div>
4242
<?php endif; ?>
43+
<?php if ($block->isRedirectToCartEnabled()) : ?>
4344
<script type="text/x-magento-init">
4445
{
4546
"#product_addtocart_form": {
@@ -49,11 +50,11 @@
4950
}
5051
}
5152
</script>
52-
<?php if (!$block->isRedirectToCartEnabled()) : ?>
53+
<?php else : ?>
5354
<script type="text/x-magento-init">
5455
{
5556
"#product_addtocart_form": {
56-
"catalogAddToCart": {}
57+
"Magento_Catalog/js/validate-product": {}
5758
}
5859
}
5960
</script>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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+
});

0 commit comments

Comments
 (0)