Skip to content

Commit 2140cd2

Browse files
committed
Merge remote-tracking branch 'af/MC-13863' into MC-13852
2 parents 066dfea + efd02f1 commit 2140cd2

File tree

3 files changed

+28
-58
lines changed

3 files changed

+28
-58
lines changed

app/code/Magento/Wishlist/Block/Customer/Wishlist/Item/Column/Cart.php

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
namespace Magento\Wishlist\Block\Customer\Wishlist\Item\Column;
88

9-
use Magento\Catalog\Controller\Adminhtml\Product\Initialization\StockDataFilter;
10-
119
/**
1210
* Wishlist block customer item cart column
1311
*
@@ -37,28 +35,4 @@ public function getProductItem()
3735
{
3836
return $this->getItem()->getProduct();
3937
}
40-
41-
/**
42-
* Get min and max qty for wishlist form.
43-
*
44-
* @return array
45-
*/
46-
public function getMinMaxQty()
47-
{
48-
$stockItem = $this->stockRegistry->getStockItem(
49-
$this->getItem()->getProduct()->getId(),
50-
$this->getItem()->getProduct()->getStore()->getWebsiteId()
51-
);
52-
53-
$params = [];
54-
55-
$params['minAllowed'] = (float)$stockItem->getMinSaleQty();
56-
if ($stockItem->getMaxSaleQty()) {
57-
$params['maxAllowed'] = (float)$stockItem->getMaxSaleQty();
58-
} else {
59-
$params['maxAllowed'] = (float)StockDataFilter::MAX_QTY_VALUE;
60-
}
61-
62-
return $params;
63-
}
6438
}

app/code/Magento/Wishlist/view/frontend/templates/item/column/cart.phtml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
/** @var \Magento\Wishlist\Model\Item $item */
1212
$item = $block->getItem();
1313
$product = $item->getProduct();
14-
$allowedQty = $block->getMinMaxQty();
1514
?>
1615
<?php foreach ($block->getChildNames() as $childName): ?>
1716
<?= /* @noEscape */ $block->getLayout()->renderElement($childName, false) ?>
@@ -22,7 +21,7 @@ $allowedQty = $block->getMinMaxQty();
2221
<div class="field qty">
2322
<label class="label" for="qty[<?= $block->escapeHtmlAttr($item->getId()) ?>]"><span><?= $block->escapeHtml(__('Qty')) ?></span></label>
2423
<div class="control">
25-
<input type="number" data-role="qty" id="qty[<?= /* @noEscape */ $block->escapeHtmlAttr($item->getId()) ?>]" class="input-text qty" data-validate="{'required-number':true,'validate-greater-than-zero':true, 'validate-item-quantity':{'minAllowed':<?= /* @noEscape */ $allowedQty['minAllowed'] ?>,'maxAllowed':<?= /* @noEscape */ $allowedQty['maxAllowed'] ?>}}"
24+
<input type="number" data-role="qty" id="qty[<?= $block->escapeHtmlAttr($item->getId()) ?>]" class="input-text qty" data-validate="{'required-number':true,'validate-greater-than-zero':true}"
2625
name="qty[<?= $block->escapeHtmlAttr($item->getId()) ?>]" value="<?= /* @noEscape */ (int)($block->getAddToCartQty($item) * 1) ?>">
2726
</div>
2827
</div>

app/code/Magento/Wishlist/view/frontend/web/js/add-to-wishlist.js

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ define([
6363
isFileUploaded = false,
6464
self = this;
6565

66+
if (event.handleObj.selector == this.options.qtyInfo) { //eslint-disable-line eqeqeq
67+
this._updateAddToWishlistButton({});
68+
event.stopPropagation();
69+
70+
return;
71+
}
6672
$(event.handleObj.selector).each(function (index, element) {
6773
if ($(element).is('input[type=text]') ||
6874
$(element).is('input[type=email]') ||
@@ -83,7 +89,9 @@ define([
8389
}
8490
});
8591

86-
this.bindFormSubmit(isFileUploaded);
92+
if (isFileUploaded) {
93+
this.bindFormSubmit();
94+
}
8795
this._updateAddToWishlistButton(dataToAdd);
8896
event.stopPropagation();
8997
},
@@ -181,45 +189,34 @@ define([
181189

182190
/**
183191
* Bind form submit.
184-
*
185-
* @param {Boolean} isFileUploaded
186192
*/
187-
bindFormSubmit: function (isFileUploaded) {
193+
bindFormSubmit: function () {
188194
var self = this;
189195

190196
$('[data-action="add-to-wishlist"]').on('click', function (event) {
191197
var element, params, form, action;
192198

193-
if (!$($(self.options.qtyInfo).closest('form')).valid()) {
194-
event.stopPropagation();
195-
event.preventDefault();
196-
197-
return;
198-
}
199-
200-
if (isFileUploaded) {
201-
202-
element = $('input[type=file]' + self.options.customOptionsInfo);
203-
params = $(event.currentTarget).data('post');
204-
form = $(element).closest('form');
205-
action = params.action;
199+
event.stopPropagation();
200+
event.preventDefault();
206201

207-
if (params.data.id) {
208-
$('<input>', {
209-
type: 'hidden',
210-
name: 'id',
211-
value: params.data.id
212-
}).appendTo(form);
213-
}
202+
element = $('input[type=file]' + self.options.customOptionsInfo);
203+
params = $(event.currentTarget).data('post');
204+
form = $(element).closest('form');
205+
action = params.action;
214206

215-
if (params.data.uenc) {
216-
action += 'uenc/' + params.data.uenc;
217-
}
207+
if (params.data.id) {
208+
$('<input>', {
209+
type: 'hidden',
210+
name: 'id',
211+
value: params.data.id
212+
}).appendTo(form);
213+
}
218214

219-
$(form).attr('action', action).submit();
220-
event.stopPropagation();
221-
event.preventDefault();
215+
if (params.data.uenc) {
216+
action += 'uenc/' + params.data.uenc;
222217
}
218+
219+
$(form).attr('action', action).submit();
223220
});
224221
}
225222
});

0 commit comments

Comments
 (0)