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 5151 <div id="cart-sidebar-reorder-advice-container"></div>
5252 <div class="actions-toolbar">
5353 <div class="primary"
54- data-bind="visible: lastOrderedItems. isShowAddToCart">
54+ data-bind="visible: isShowAddToCart">
5555 <button type="submit" title="<?= /* @escapeNotVerified */ __ ('Add to Cart ' ) ?> " class="action tocart primary">
5656 <span><?= /* @escapeNotVerified */ __ ('Add to Cart ' ) ?> </span>
5757 </button>
Original file line number Diff line number Diff line change @@ -11,18 +11,37 @@ define([
1111 'use strict' ;
1212
1313 return Component . extend ( {
14+ defaults : {
15+ isShowAddToCart : false
16+ } ,
17+
1418 /** @inheritdoc */
1519 initialize : function ( ) {
16- var isShowAddToCart ;
17-
1820 this . _super ( ) ;
1921 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+ } ,
2035
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 , {
2241 'is_saleable' : true
2342 } ) ;
2443
25- this . lastOrderedItems . isShowAddToCart = isShowAddToCart ;
44+ this . isShowAddToCart ( isShowAddToCart ) ;
2645 }
2746 } ) ;
2847} ) ;
You can’t perform that action at this time.
0 commit comments