@@ -68,24 +68,33 @@ private function sendPushNotifications(OrderInterface $order)
68
68
}
69
69
70
70
foreach ($ order ->getItems () as $ orderItem ) {
71
+ if ($ orderItem ->getHasChildren () == true ) {
72
+ // Skip parent items (configurable product parents etc)
73
+ continue ;
74
+ }
75
+
71
76
// Retrieve the salable qty of the product based on configured scope
72
77
$ salableQty = $ this ->getSalableQty (
73
78
$ orderItem ->getProduct (),
74
79
$ stockPushScope
75
80
);
76
81
77
- // if salable qty is set and not already 0, check if push is required (null infers manage stock is disabled)
78
- if ($ salableQty !== null && $ salableQty > 0 ) {
79
- // Calculate new salabale quantity (after order placement)
80
- $ salableQtyAfterOrder = $ salableQty - $ orderItem ->getQtyOrdered ();
81
- if ($ salableQtyAfterOrder <= 0 ) {
82
- $ stockData = $ this ->inventoryService ->getPushApiStockData (
83
- (int )$ orderItem ->getProductId (),
84
- false
85
- );
86
-
87
- $ this ->pushApiService ->pushRequest ($ stockData );
88
- }
82
+ if ($ this ->inventoryService ->isReservationsAfter ()) {
83
+ /*
84
+ * Adjust salable qty to compensate for a core API inconsistency across Magento versions
85
+ * which affects the salable quantity calculation based on the order in which reservations are deducted.
86
+ */
87
+ $ salableQty = $ salableQty - $ orderItem ->getQtyOrdered ();
88
+ }
89
+
90
+ // If salable qty is set, check if push is required for zero stock (null implies manage stock is disabled)
91
+ if ($ salableQty !== null && $ salableQty <= 0 ) {
92
+ $ stockData = $ this ->inventoryService ->getPushApiStockData (
93
+ (int )$ orderItem ->getProductId (),
94
+ false
95
+ );
96
+
97
+ $ this ->pushApiService ->pushRequest ($ stockData );
89
98
}
90
99
}
91
100
}
0 commit comments