File tree 1 file changed +15
-0
lines changed
app/code/Magento/Downloadable/Observer
1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -61,6 +61,7 @@ public function execute(\Magento\Framework\Event\Observer $observer)
61
61
'payment_pending ' => \Magento \Downloadable \Model \Link \Purchased \Item::LINK_STATUS_PENDING_PAYMENT ,
62
62
'payment_review ' => \Magento \Downloadable \Model \Link \Purchased \Item::LINK_STATUS_PAYMENT_REVIEW ,
63
63
];
64
+ $ expiredOrderItemIds = [];
64
65
65
66
$ downloadableItemsStatuses = [];
66
67
$ orderItemStatusToEnable = $ this ->_scopeConfig ->getValue (
@@ -114,6 +115,10 @@ public function execute(\Magento\Framework\Event\Observer $observer)
114
115
if (in_array ($ item ->getStatusId (), $ availableStatuses )) {
115
116
$ downloadableItemsStatuses [$ item ->getId ()] = $ linkStatuses ['avail ' ];
116
117
}
118
+
119
+ if ($ item ->getQtyOrdered () - $ item ->getQtyRefunded () == 0 ) {
120
+ $ expiredOrderItemIds [] = $ item ->getId ();
121
+ }
117
122
}
118
123
}
119
124
}
@@ -141,6 +146,16 @@ public function execute(\Magento\Framework\Event\Observer $observer)
141
146
}
142
147
}
143
148
149
+ if ($ expiredOrderItemIds ) {
150
+ $ linkPurchased = $ this ->_createItemsCollection ()->addFieldToFilter (
151
+ 'order_item_id ' ,
152
+ ['in ' => $ expiredOrderItemIds ]
153
+ );
154
+ foreach ($ linkPurchased as $ link ) {
155
+ $ link ->setStatus (\Magento \Downloadable \Model \Link \Purchased \Item::LINK_STATUS_EXPIRED )->save ();
156
+ }
157
+ }
158
+
144
159
return $ this ;
145
160
}
146
161
You can’t perform that action at this time.
0 commit comments