- Status changed to Needs work
about 1 year ago 1:18am 14 September 2023 - 🇺🇸United States loze Los Angeles
This part is wrong.
- + if ($item->getOriginal == NULL || $item == NULL) { + return; + } if ($order && !in_array($order->getState()->value, ['draft', 'canceled'])) {
$item->getOriginal is always going to return null. Im not sure what its trying to accomplish here.
- 🇪🇸Spain interdruper
@loze is right, that snippet always will be true, and the return will be executed.
$item cannot be null (since it triggers the event), so the check just can be:
if ($item->original) { return; } if ($order && !in_array($order->getState()->value, ['draft', 'canceled'])) { $diff = $item->original->getQuantity() - $item->getQuantity();
for avoiding the warning if $item->Original is NULL.
The code that truly fixes the issue error is the other snippet contained in the patch:
@@ -158,7 +160,7 @@ class OrderEventSubscriber implements EventSubscriberInterface { */ public function onOrderUpdate(OrderEvent $event) { $order = $event->getOrder(); - $original_order = $order->original; + $original_order = empty($order->original) ? $order : $order->original; $allow_negative = \Drupal::config('commerce_simple_stock.settings')->get('allow_backorder'); if ($original_order) {
- Status changed to Needs review
about 1 year ago 7:50am 13 November 2023 - 🇮🇳India roshni27
I have implemented the modifications as per issue #6. please review the patch.