File tree Expand file tree Collapse file tree 2 files changed +24
-5
lines changed
app/code/Magento/Sales/view/frontend Expand file tree Collapse file tree 2 files changed +24
-5
lines changed Original file line number Diff line number Diff line change 51
51
<div id="cart-sidebar-reorder-advice-container"></div>
52
52
<div class="actions-toolbar">
53
53
<div class="primary"
54
- data-bind="visible: lastOrderedItems. isShowAddToCart">
54
+ data-bind="visible: isShowAddToCart">
55
55
<button type="submit" title="<?= /* @escapeNotVerified */ __ ('Add to Cart ' ) ?> " class="action tocart primary">
56
56
<span><?= /* @escapeNotVerified */ __ ('Add to Cart ' ) ?> </span>
57
57
</button>
Original file line number Diff line number Diff line change @@ -11,18 +11,37 @@ define([
11
11
'use strict' ;
12
12
13
13
return Component . extend ( {
14
+ defaults : {
15
+ isShowAddToCart : false
16
+ } ,
17
+
14
18
/** @inheritdoc */
15
19
initialize : function ( ) {
16
- var isShowAddToCart ;
17
-
18
20
this . _super ( ) ;
19
21
this . lastOrderedItems = customerData . get ( 'last-ordered-items' ) ;
22
+ this . lastOrderedItems . subscribe ( this . checkSalableItems . bind ( this ) ) ;
23
+ this . checkSalableItems ( ) ;
24
+
25
+ return this ;
26
+ } ,
27
+
28
+ /** @inheritdoc */
29
+ initObservable : function ( ) {
30
+ this . _super ( )
31
+ . observe ( 'isShowAddToCart' ) ;
32
+
33
+ return this ;
34
+ } ,
20
35
21
- isShowAddToCart = _ . some ( this . lastOrderedItems ( ) . items , {
36
+ /**
37
+ * Check if items is_saleable and change add to cart button visibility.
38
+ */
39
+ checkSalableItems : function ( ) {
40
+ var isShowAddToCart = _ . some ( this . lastOrderedItems ( ) . items , {
22
41
'is_saleable' : true
23
42
} ) ;
24
43
25
- this . lastOrderedItems . isShowAddToCart = isShowAddToCart ;
44
+ this . isShowAddToCart ( isShowAddToCart ) ;
26
45
}
27
46
} ) ;
28
47
} ) ;
You can’t perform that action at this time.
0 commit comments