Error when used in combination with Commerce Repeat Order

Created on 17 August 2022, over 2 years ago
Updated 8 July 2024, 5 months ago

I get an error when I use this module in combinantion with
https://www.drupal.org/project/commerce_repeat_order โ†’

Not sure which module is the problem. See also:
https://www.drupal.org/project/commerce_repeat_order/issues/3194700 โ†’

The error after repeating an order is:
Error: Call to a member function getQuantity() on null in Drupal\commerce_simple_stock\EventSubscriber\OrderEventSubscriber->preSaveOrderItem() (line 120 of modules/contrib/commerce_simple_stock/src/EventSubscriber/OrderEventSubscriber.php).

๐Ÿ› Bug report
Status

Active

Version

1.1

Component

Code

Created by

๐Ÿ‡ณ๐Ÿ‡ฑNetherlands ecvandenberg

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly nikolino

    I have the same error but I don't use Commerce Repeat Order. When I modify an order by adding a new product I get this error.
    Anyone have the same problem?

  • ananya.k โ†’ made their first commit to this issueโ€™s fork.

  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand luke.stewart

    I've also hit this when using a custom module to duplicate a line Item when rescheduling a booking make via a custom implementation to drupal.org/project/bee.

    I have a workaround which is to save the orderItem then add it to the order after it's been saved.

    I thought perhaps I was doing things that I shouldn't have but spotted this so I think the more complete solution here is to ensure there is an original item.

  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand luke.stewart

    The MR just wraps the presave in a test to check if the original item exists. This will fix the fatal.
    I suspect that what we actually want here is to set diff to "- $item->getQuantity()" if original is null. but I'm not familiar enough with this module to comment or comprehend. I'd definitely recommend testing the behaviour of the linked stock field before and after applying the above as a patch to ensure it is decrementing it where as before it would have issued a fatal.

  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands ecvandenberg

    For some reason I have the combination of this module with commerce repeat order working well.
    This is the config that works well:

    • Drupal 10.3.10
    • Commerce Core 8.x-2.40
    • Commerce Simple Stock 8.x-1.2 with patch 3450194
    • Commerce Repeat Order 8.x-2.2 with patch 3367273

    Many months ago I had both patches installed too, but repeating an order resulted in errors.
    Now it works great. I guess due to updates on other modules.

Production build 0.71.5 2024