Skip to content

Commit c333367

Browse files
#13157 - Last Ordered Items block - bad js code
1 parent da1a96c commit c333367

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

app/code/Magento/Sales/view/frontend/templates/reorder/sidebar.phtml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,18 @@
2626
<ol id="cart-sidebar-reorder" class="product-items product-items-names"
2727
data-bind="foreach: lastOrderedItems().items">
2828
<li class="product-item">
29-
<div class="field item choice no-display" data-bind="css: {'no-display': !is_saleable}">
29+
<div class="field item choice">
3030
<label class="label" data-bind="attr: {'for': 'reorder-item-' + id}">
3131
<span><?= /* @escapeNotVerified */ __('Add to Cart') ?></span>
3232
</label>
3333
<div class="control">
3434
<input type="checkbox" name="order_items[]"
35-
data-bind="attr: {id: 'reorder-item-' + id, value: id}"
36-
title="<?= /* @escapeNotVerified */ __('Add to Cart') ?>"
35+
data-bind="attr: {
36+
id: 'reorder-item-' + id,
37+
value: id,
38+
title: is_saleable ? '<?= /* @escapeNotVerified */ __('Add to Cart') ?>' : '<?= /* @escapeNotVerified */ __('Product is not salable.') ?>'
39+
},
40+
disable: !is_saleable"
3741
class="checkbox" data-validate='{"validate-one-checkbox-required-by-name": true}'/>
3842
</div>
3943
</div>
@@ -46,8 +50,8 @@
4650
</ol>
4751
<div id="cart-sidebar-reorder-advice-container"></div>
4852
<div class="actions-toolbar">
49-
<div class="primary no-display"
50-
data-bind="css: {'no-display': !lastOrderedItems().isShowAddToCart}">
53+
<div class="primary"
54+
data-bind="visible: lastOrderedItems.isShowAddToCart">
5155
<button type="submit" title="<?= /* @escapeNotVerified */ __('Add to Cart') ?>" class="action tocart primary">
5256
<span><?= /* @escapeNotVerified */ __('Add to Cart') ?></span>
5357
</button>

app/code/Magento/Sales/view/frontend/web/js/view/last-ordered-items.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,14 @@ define([
1212
return Component.extend({
1313
/** @inheritdoc */
1414
initialize: function () {
15-
var isShowAddToCart = false,
16-
item;
15+
var isShowAddToCart;
1716

1817
this._super();
1918
this.lastOrderedItems = customerData.get('last-ordered-items');
2019

21-
for (item in this.lastOrderedItems.items) {
22-
if (item['is_saleable']) {
23-
isShowAddToCart = true;
24-
break;
25-
}
26-
}
20+
isShowAddToCart = _.some(this.lastOrderedItems().items, {
21+
'is_saleable': true
22+
});
2723

2824
this.lastOrderedItems.isShowAddToCart = isShowAddToCart;
2925
}

0 commit comments

Comments
 (0)