AssertionError: assert($form_object instanceof OrderForm)

Created on 30 December 2020, almost 5 years ago
Updated 19 August 2025, 2 months ago

I get this error when i click add to cart buttom:

AssertionError: assert($form_object instanceof OrderForm) in assert() (line 181 of /opt/drupal/web/modules/contrib/commerce/modules/order/src/Plugin/Field/FieldWidget/UnitPriceWidget.php)
#0 /opt/drupal/web/modules/contrib/commerce/modules/order/src/Plugin/Field/FieldWidget/UnitPriceWidget.php(181): assert(false, 'assert($form_ob...')
#1 /opt/drupal/web/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php(232): Drupal\commerce_order\Plugin\Field\FieldWidget\UnitPriceWidget->extractFormValues(Object(Drupal\Core\Field\FieldItemList), Array, Object(Drupal\Core\Form\FormState))
#2 /opt/drupal/web/core/lib/Drupal/Core/Entity/ContentEntityForm.php(338): Drupal\Core\Entity\Entity\EntityFormDisplay->extractFormValues(Object(Drupal\commerce_order\Entity\OrderItem), Array, Object(Drupal\Core\Form\FormState))
#3 /opt/drupal/web/core/lib/Drupal/Core/Entity/EntityForm.php(336): Drupal\Core\Entity\ContentEntityForm->copyFormValuesToEntity(Object(Drupal\commerce_order\Entity\OrderItem), Array, Object(Drupal\Core\Form\FormState))
#4 /opt/drupal/web/core/lib/Drupal/Core/Entity/ContentEntityForm.php(159): Drupal\Core\Entity\EntityForm->buildEntity(Array, Object(Drupal\Core\Form\FormState))
#5 /opt/drupal/web/modules/contrib/commerce/modules/cart/src/Form/AddToCartForm.php(223): Drupal\Core\Entity\ContentEntityForm->buildEntity(Array, Object(Drupal\Core\Form\FormState))
#6 /opt/drupal/web/core/lib/Drupal/Core/Entity/ContentEntityForm.php(190): Drupal\commerce_cart\Form\AddToCartForm->buildEntity(Array, Object(Drupal\Core\Form\FormState))
#7 [internal function]: Drupal\Core\Entity\ContentEntityForm->validateForm(Array, Object(Drupal\Core\Form\FormState))
#8 /opt/drupal/web/core/lib/Drupal/Core/Form/FormValidator.php(82): call_user_func_array(Array, Array)
#9 /opt/drupal/web/core/lib/Drupal/Core/Form/FormValidator.php(273): Drupal\Core\Form\FormValidator->executeValidateHandlers(Array, Object(Drupal\Core\Form\FormState))
#10 /opt/drupal/web/core/lib/Drupal/Core/Form/FormValidator.php(118): Drupal\Core\Form\FormValidator->doValidateForm(Array, Object(Drupal\Core\Form\FormState), 'commerce_order_...')
#11 /opt/drupal/web/core/lib/Drupal/Core/Form/FormBuilder.php(589): Drupal\Core\Form\FormValidator->validateForm('commerce_order_...', Array, Object(Drupal\Core\Form\FormState))
#12 /opt/drupal/web/core/lib/Drupal/Core/Form/FormBuilder.php(321): Drupal\Core\Form\FormBuilder->processForm('commerce_order_...', Array, Object(Drupal\Core\Form\FormState))
#13 /opt/drupal/web/modules/contrib/dc_ajax_add_cart/src/ProductLazyBuilders.php(80): Drupal\Core\Form\FormBuilder->buildForm(Object(Drupal\dc_ajax_add_cart\Form\AjaxAddToCartForm), Object(Drupal\Core\Form\FormState))
#14 [internal function]: Drupal\dc_ajax_add_cart\ProductLazyBuilders->ajaxAddToCartForm('2', 'full', true)
#15 /opt/drupal/web/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php(100): call_user_func_array(Array, Array)
#16 /opt/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(781): Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #lazy_bu...', 'silenced_deprec...', 'Drupal\\Core\\Ren...')
#17 /opt/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(355): Drupal\Core\Render\Renderer->doCallback('#lazy_builder', Array, Array)
#18 /opt/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(444): Drupal\Core\Render\Renderer->doRender(Array)
#19 /opt/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(200): Drupal\Core\Render\Renderer->doRender(Array, false)
#20 /opt/drupal/web/core/lib/Drupal/Core/Template/TwigExtension.php(501): Drupal\Core\Render\Renderer->render(Array)
#21 /opt/drupal/vendor/twig/twig/src/Environment.php(497) : eval()'d code(84): Drupal\Core\Template\TwigExtension->escapeFilter(Object(Drupal\Core\Template\TwigEnvironment), Array, 'html', NULL, true)
#22 /opt/drupal/vendor/twig/twig/src/Template.php(455): __TwigTemplate_1bce8117058ba8667391594aa2805727aeb6231a38b5fb837509d37a6e14bce4->doDisplay(Array, Array)
#23 /opt/drupal/vendor/twig/twig/src/Template.php(422): Twig\Template->displayWithErrorHandling(Array, Array)
#24 /opt/drupal/vendor/twig/twig/src/Template.php(434): Twig\Template->display(Array)
#25 /opt/drupal/web/core/themes/engines/twig/twig.engine(64): Twig\Template->render(Array)
#26 /opt/drupal/web/core/lib/Drupal/Core/Theme/ThemeManager.php(384): twig_render_template('core/themes/cla...', Array)
#27 /opt/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(431): Drupal\Core\Theme\ThemeManager->render('field', Array)
#28 /opt/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(200): Drupal\Core\Render\Renderer->doRender(Array, false)
#29 /opt/drupal/web/core/lib/Drupal/Core/Template/TwigExtension.php(501): Drupal\Core\Render\Renderer->render(Array)
#30 /opt/drupal/vendor/twig/twig/src/Environment.php(497) : eval()'d code(108): Drupal\Core\Template\TwigExtension->escapeFilter(Object(Drupal\Core\Template\TwigEnvironment), Array, 'html', NULL, true)
#31 /opt/drupal/vendor/twig/twig/src/Template.php(455): __TwigTemplate_36f66e50d710b224018b641c667f69fd93db5d13c9072eff2068cc638fc0285c->doDisplay(Array, Array)
#32 /opt/drupal/vendor/twig/twig/src/Template.php(422): Twig\Template->displayWithErrorHandling(Array, Array)
#33 /opt/drupal/vendor/twig/twig/src/Template.php(434): Twig\Template->display(Array)
#34 /opt/drupal/web/core/themes/engines/twig/twig.engine(64): Twig\Template->render(Array)
#35 /opt/drupal/web/core/lib/Drupal/Core/Theme/ThemeManager.php(384): twig_render_template('themes/custom/f...', Array)
#36 /opt/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(431): Drupal\Core\Theme\ThemeManager->render('commerce_produc...', Array)
#37 /opt/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(200): Drupal\Core\Render\Renderer->doRender(Array, false)
#38 /opt/drupal/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(226): Drupal\Core\Render\Renderer->render(Array, false)
#39 /opt/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(573): Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}()
#40 /opt/drupal/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(227): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#41 /opt/drupal/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(117): Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\CurrentRouteMatch))
#42 /opt/drupal/web/core/lib/Drupal/Core/EventSubscriber/MainContentViewSubscriber.php(90): Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\CurrentRouteMatch))
#43 [internal function]: Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object(Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent), 'kernel.view', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#44 /opt/drupal/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(111): call_user_func(Array, Object(Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent), 'kernel.view', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#45 /opt/drupal/vendor/symfony/http-kernel/HttpKernel.php(156): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object(Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent))
#46 /opt/drupal/vendor/symfony/http-kernel/HttpKernel.php(68): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#47 /opt/drupal/web/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#48 /opt/drupal/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#49 /opt/drupal/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#50 /opt/drupal/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#51 /opt/drupal/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#52 /opt/drupal/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#53 /opt/drupal/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#54 /opt/drupal/web/core/lib/Drupal/Core/DrupalKernel.php(708): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#55 /opt/drupal/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#56 {main}
🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇮🇹Italy trickfun

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.

Production build 0.71.5 2024