Error: Call to a member function getPlugin() on null in Drupal\commerce_recurring\EventSubscriber\OrderSubscriber->onPlace()

Created on 2 December 2019, almost 5 years ago
Updated 30 January 2023, almost 2 years ago

I encountered the following error testing Subscription billing with Commerce recurring on drupal 8. The error happens at checkout, I added a custom field to contain 'billing schedule' on the user form in the line item. I think it stays empty (null). The field is reference to entity billing schedule.

I have no idea what is going wrong, this worked ok when first installed I believe. Any suggestions?

Error: Call to a member function getPlugin() on null in Drupal\commerce_recurring\EventSubscriber\OrderSubscriber->onPlace() (regel 90 van /data/sites/web/myassistbe/subsites/d8.als.myassist.be/d8als/web/modules/commerce_recurring/src/EventSubscriber/OrderSubscriber.php) #0 [internal function]: Drupal\commerce_recurring\EventSubscriber\OrderSubscriber->onPlace(Object(Drupal\state_machine\Event\WorkflowTransitionEvent), 'commerce_order....', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher)) #1 /data/sites/web/myassistbe/subsites/d8.als.myassist.be/d8als/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(111): call_user_func(Array, Object(Drupal\state_machine\Event\WorkflowTransitionEvent), 'commerce_order....', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher)) #2 /data/sites/web/myassistbe/subsites/d8.als.myassist.be/d8als/web/modules/contrib/state_machine/src/Plugin/Field/FieldType/StateItem.php(361): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('commerce_order....', Object(Drupal\state_machine\Event\WorkflowTransitionEvent)) #3 /data/sites/web/myassistbe/subsites/d8.als.myassist.be/d8als/web/modules/contrib/state_machine/src/Plugin/Field/FieldType/StateItem.php(322): Drupal\state_machine\Plugin\Field\FieldType\StateItem->dispatchTransitionEvent('pre_transition') #4 /data/sites/web/myassistbe/subsites/d8.als.myassist.be/d8als/web/core/lib/Drupal/Core/Field/FieldItemList.php(233): Drupal\state_machine\Plugin\Field\FieldType\StateItem->preSave() #5 /data/sites/web/myassistbe/subsites/d8.als.myassist.be/d8als/web/core/lib/Drupal/Core/Field/FieldItemList.php(191): Drupal\Core\Field\FieldItemList->delegateMethod('preSave') #6 /data/sites/web/myassistbe/subsites/d8.als.myassist.be/d8als/web/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php(873): Drupal\Core\Field\FieldItemList->preSave() #7 /data/sites/web/myassistbe/subsites/d8.als.myassist.be/d8als/web/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php(823): Drupal\Core\Entity\ContentEntityStorageBase->invokeFieldMethod('preSave', Object(Drupal\commerce_order\Entity\Order)) #8 /data/sites/web/myassistbe/subsites/d8.als.myassist.be/d8als/web/modules/contrib/commerce/src/CommerceContentEntityStorage.php(100): Drupal\Core\Entity\ContentEntityStorageBase->invokeHook('presave', Object(Drupal\commerce_order\Entity\Order)) #9 /data/sites/web/myassistbe/subsites/d8.als.myassist.be/d8als/web/modules/contrib/commerce/modules/order/src/OrderStorage.php(111): Drupal\commerce\CommerceContentEntityStorage->invokeHook('presave', Object(Drupal\commerce_order\Entity\Order)) #10 /data/sites/web/myassistbe/subsites/d8.als.myassist.be/d8als/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(500): Drupal\commerce_order\OrderStorage->invokeHook('presave', Object(Drupal\commerce_order\Entity\Order)) #11 /data/sites/web/myassistbe/subsites/d8.als.myassist.be/d8als/web/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php(692): Drupal\Core\Entity\EntityStorageBase->doPreSave(Object(Drupal\commerce_order\Entity\Order)) #12 /data/sites/web/myassistbe/subsites/d8.als.myassist.be/d8als/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(454): Drupal\Core\Entity\ContentEntityStorageBase->doPreSave(Object(Drupal\commerce_order\Entity\Order)) #13 /data/sites/web/myassistbe/subsites/d8.als.myassist.be/d8als/web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php(838): Drupal\Core\Entity\EntityStorageBase->save(Object(Drupal\commerce_order\Entity\Order)) #14 /data/sites/web/myassistbe/subsites/d8.als.myassist.be/d8als/web/core/lib/Drupal/Core/Entity/EntityBase.php(394): Drupal\Core\Entity\Sql\SqlContentEntityStorage->save(Object(Drupal\commerce_order\Entity\Order)) #15 /data/sites/web/myassistbe/subsites/d8.als.myassist.be/d8als/web/modules/contrib/commerce/modules/checkout/src/Plugin/Commerce/CheckoutFlow/CheckoutFlowBase.php(139): Drupal\Core\Entity\EntityBase->save() #16 /data/sites/web/myassistbe/subsites/d8.als.myassist.be/d8als/web/modules/contrib/commerce/modules/payment/src/Plugin/Commerce/CheckoutPane/PaymentProcess.php(180): Drupal\commerce_checkout\Plugin\Commerce\CheckoutFlow\CheckoutFlowBase->redirectToStep('complete') #17 /data/sites/web/myassistbe/subsites/d8.als.myassist.be/d8als/web/modules/contrib/commerce/modules/checkout/src/Plugin/Commerce/CheckoutFlow/CheckoutFlowWithPanesBase.php(559): Drupal\commerce_payment\Plugin\Commerce\CheckoutPane\PaymentProcess->buildPaneForm(Array, Object(Drupal\Core\Form\FormState), Array) #18 [internal function]: Drupal\commerce_checkout\Plugin\Commerce\CheckoutFlow\CheckoutFlowWithPanesBase->buildForm(Array, Object(Drupal\Core\Form\FormState), 'payment') #19 /data/sites/web/myassistbe/subsites/d8.als.myassist.be/d8als/web/core/lib/Drupal/Core/Form/FormBuilder.php(519): call_user_func_array(Array, Array) #20 /data/sites/web/myassistbe/subsites/d8.als.myassist.be/d8als/web/core/lib/Drupal/Core/Form/FormBuilder.php(276): Drupal\Core\Form\FormBuilder->retrieveForm('commerce_checko...', Object(Drupal\Core\Form\FormState)) #21 /data/sites/web/myassistbe/subsites/d8.als.myassist.be/d8als/web/core/lib/Drupal/Core/Form/FormBuilder.php(217): Drupal\Core\Form\FormBuilder->buildForm(Object(Drupal\commerce_checkout\Plugin\Commerce\CheckoutFlow\MultistepDefault), Object(Drupal\Core\Form\FormState)) #22 /data/sites/web/myassistbe/subsites/d8.als.myassist.be/d8als/web/modules/contrib/commerce/modules/checkout/src/Controller/CheckoutController.php(94): Drupal\Core\Form\FormBuilder->getForm(Object(Drupal\commerce_checkout\Plugin\Commerce\CheckoutFlow\MultistepDefault), 'payment') #23 [internal function]: Drupal\commerce_checkout\Controller\CheckoutController->formPage(Object(Drupal\Core\Routing\RouteMatch)) #24 /data/sites/web/myassistbe/subsites/d8.als.myassist.be/d8als/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array) #25 /data/sites/web/myassistbe/subsites/d8.als.myassist.be/d8als/web/core/lib/Drupal/Core/Render/Renderer.php(582): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #26 /data/sites/web/myassistbe/subsites/d8.als.myassist.be/d8als/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure)) #27 /data/sites/web/myassistbe/subsites/d8.als.myassist.be/d8als/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) #28 /data/sites/web/myassistbe/subsites/d8.als.myassist.be/d8als/vendor/symfony/http-kernel/HttpKernel.php(151): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #29 /data/sites/web/myassistbe/subsites/d8.als.myassist.be/d8als/vendor/symfony/http-kernel/HttpKernel.php(68): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1) #30 /data/sites/web/myassistbe/subsites/d8.als.myassist.be/d8als/web/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #31 /data/sites/web/myassistbe/subsites/d8.als.myassist.be/d8als/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #32 /data/sites/web/myassistbe/subsites/d8.als.myassist.be/d8als/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #33 /data/sites/web/myassistbe/subsites/d8.als.myassist.be/d8als/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true) #34 /data/sites/web/myassistbe/subsites/d8.als.myassist.be/d8als/web/core/modules/ban/src/BanMiddleware.php(50): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #35 /data/sites/web/myassistbe/subsites/d8.als.myassist.be/d8als/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\ban\BanMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #36 /data/sites/web/myassistbe/subsites/d8.als.myassist.be/d8als/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #37 /data/sites/web/myassistbe/subsites/d8.als.myassist.be/d8als/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #38 /data/sites/web/myassistbe/subsites/d8.als.myassist.be/d8als/web/core/lib/Drupal/Core/DrupalKernel.php(693): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #39 /data/sites/web/myassistbe/subsites/d8.als.myassist.be/d8als/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request)) #40 {main}./code>

💬 Support request
Status

Fixed

Version

1.0

Component

Code

Created by

🇧🇪Belgium herftijd

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.

  • 🇳🇱Netherlands huijse

    I encountered the same problem at checkout. Is there someone who has a solution yet?

    /** @var \Drupal\commerce_recurring\Entity\BillingScheduleInterface $billing_schedule */
          $billing_schedule = $billing_schedule_item->entity;
          // If the trial is not allowed and no payment method was collected, we
          // cannot proceed to the subscription creation.
          if (!$billing_schedule->getPlugin()->allowTrials() && empty($payment_method)) {
            continue;
          }

    I guess the error is thrown because the $billing_schedule is null. I checked and the entity is configured. But perhaps it does not query the correct one.

    I am going to start over and follow the steps in the readme.

    Error: Call to a member function getPlugin() on null in Drupal\commerce_recurring\EventSubscriber\OrderSubscriber->onPlace() (line 90 of modules/contrib/commerce_recurring/src/EventSubscriber/OrderSubscriber.php)

  • 🇮🇱Israel jsacksick

    So this probably means the billing schedule referenced was deleted or something?

  • Status changed to Fixed almost 2 years ago
  • 🇮🇱Israel jsacksick

    So, adding a condition to check if the billing schedule is going to fix the crash, but the subscription isn't going to be created... So I guess, it's somehow better than it doesn't silently fail..

    So you'd need to edit this product variation and make sure it's linked to an existing billing schedule.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024