Update VadoGroupAddToCartForm to work with changes in commerce core.

Created on 26 January 2024, 5 months ago
Updated 10 February 2024, 5 months ago

Problem/Motivation

Commerce breaks the add to cart form see 🐛 Latest dev release of commerce core breaks commerce_pado on addToCart submit RTBC

TypeError: Drupal\commerce\Context::__construct(): Argument #1 ($customer) must be of type Drupal\Core\Session\AccountInterface, null given, called in /var/www/html/web/modules/contrib/commerce/modules/cart/src/Form/AddToCartForm.php on line 248 in Drupal\commerce\Context->__construct() (line 58 of /var/www/html/web/modules/contrib/commerce/src/Context.php).

Full backtrace:

#0 /var/www/html/web/modules/contrib/commerce/modules/cart/src/Form/AddToCartForm.php(248): Drupal\commerce\Context->__construct(NULL, Object(Drupal\commerce_store\Entity\Store))
#1 /var/www/html/web/modules/contrib/commerce/modules/cart/src/Form/AddToCartForm.php(232): Drupal\commerce_cart\Form\AddToCartForm->prepareOrderItem(Object(Drupal\commerce_order\Entity\OrderItem))
#2 /var/www/html/web/modules/contrib/commerce_vado/src/Form/VadoGroupAddToCartForm.php(190): Drupal\commerce_cart\Form\AddToCartForm->buildEntity(Array, Object(Drupal\Core\Form\FormState))
#3 /var/www/html/web/core/lib/Drupal/Core/Entity/ContentEntityForm.php(186): Drupal\commerce_vado\Form\VadoGroupAddToCartForm->buildEntity(Array, Object(Drupal\Core\Form\FormState))
#4 [internal function]: Drupal\Core\Entity\ContentEntityForm->validateForm(Array, Object(Drupal\Core\Form\FormState))
#5 /var/www/html/web/core/lib/Drupal/Core/Form/FormValidator.php(82): call_user_func_array(Array, Array)
#6 /var/www/html/web/core/lib/Drupal/Core/Form/FormValidator.php(275): Drupal\Core\Form\FormValidator->executeValidateHandlers(Array, Object(Drupal\Core\Form\FormState))
#7 /var/www/html/web/core/lib/Drupal/Core/Form/FormValidator.php(118): Drupal\Core\Form\FormValidator->doValidateForm(Array, Object(Drupal\Core\Form\FormState), 'commerce_order_...')
#8 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(593): Drupal\Core\Form\FormValidator->validateForm('commerce_order_...', Array, Object(Drupal\Core\Form\FormState))
#9 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(325): Drupal\Core\Form\FormBuilder->processForm('commerce_order_...', Array, Object(Drupal\Core\Form\FormState))
#10 /var/www/html/web/modules/contrib/commerce_vado/src/VadoGroupLazyBuilders.php(52): Drupal\Core\Form\FormBuilder->buildForm(Object(Drupal\commerce_vado\Form\VadoGroupAddToCartForm), Object(Drupal\Core\Form\FormState))
#11 [internal function]: Drupal\commerce_vado\VadoGroupLazyBuilders->addToCartWithAddOnsForm('1198', 'full', true)
#12 /var/www/html/web/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php(111): call_user_func_array(Array, Array)
#13 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(858): Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #lazy_bu...', 'exception', 'Drupal\\Core\\Ren...')
#14 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(400): Drupal\Core\Render\Renderer->doCallback('#lazy_builder', 'commerce_vado.l...', Array)
#15 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(493): Drupal\Core\Render\Renderer->doRender(Array)
#16 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(240): Drupal\Core\Render\Renderer->doRender(Array, false)
#17 /var/www/html/web/core/lib/Drupal/Core/Template/TwigExtension.php(475): Drupal\Core\Render\Renderer->render(Array)
#18 /var/www/html/web/sites/default/files/php/twig/65b2a2b57862a_field.html.twig_imtDqHgHhHKhF9RUawwio7DgF/QH28UHQzbt-0tGjW0fkIyFLmFzfOw2jMEiag0W06FhU.php(125): Drupal\Core\Template\TwigExtension->escapeFilter(Object(Drupal\Core\Template\TwigEnvironment), Array, 'html', NULL, true)
#19 /var/www/html/vendor/twig/twig/src/Template.php(394): __TwigTemplate_006d1218638f0c54efc04f12b81a1d9e->doDisplay(Array, Array)
#20 /var/www/html/vendor/twig/twig/src/Template.php(367): Twig\Template->displayWithErrorHandling(Array, Array)
#21 /var/www/html/vendor/twig/twig/src/Template.php(379): Twig\Template->display(Array)
#22 /var/www/html/vendor/twig/twig/src/TemplateWrapper.php(38): Twig\Template->render(Array)
#23 /var/www/html/web/core/themes/engines/twig/twig.engine(39): Twig\TemplateWrapper->render(Array)
#24 /var/www/html/web/core/lib/Drupal/Core/Theme/ThemeManager.php(348): twig_render_template('themes/contrib/...', Array)
#25 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(480): Drupal\Core\Theme\ThemeManager->render('field', Array)
#26 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(493): Drupal\Core\Render\Renderer->doRender(Array)
#27 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(240): Drupal\Core\Render\Renderer->doRender(Array, false)
#28 /var/www/html/web/core/lib/Drupal/Core/Template/TwigExtension.php(475): Drupal\Core\Render\Renderer->render(Array)
#29 /var/www/html/web/sites/default/files/php/twig/65b2a2b57862a_commerce-product.html.twi_UfQKjONuKaJEq2mWlxnnNJQgL/jKebAVKtIVy3SaMByFqbv-blF-Pt9RGSdxmD-cay9f0.php(50): Drupal\Core\Template\TwigExtension->escapeFilter(Object(Drupal\Core\Template\TwigEnvironment), Array, 'html', NULL, true)
#30 /var/www/html/vendor/twig/twig/src/Template.php(394): __TwigTemplate_c3efdc302e61d420f74b0c803a4ce816->doDisplay(Array, Array)
#31 /var/www/html/vendor/twig/twig/src/Template.php(367): Twig\Template->displayWithErrorHandling(Array, Array)
#32 /var/www/html/vendor/twig/twig/src/Template.php(379): Twig\Template->display(Array)
#33 /var/www/html/vendor/twig/twig/src/TemplateWrapper.php(38): Twig\Template->render(Array)
#34 /var/www/html/web/core/themes/engines/twig/twig.engine(39): Twig\TemplateWrapper->render(Array)
#35 /var/www/html/web/core/lib/Drupal/Core/Theme/ThemeManager.php(348): twig_render_template('modules/contrib...', Array)
#36 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(480): Drupal\Core\Theme\ThemeManager->render('commerce_produc...', Array)
#37 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(240): Drupal\Core\Render\Renderer->doRender(Array, false)
#38 /var/www/html/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(238): Drupal\Core\Render\Renderer->render(Array, false)
#39 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(627): Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}()
#40 /var/www/html/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(231): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#41 /var/www/html/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(128): Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\CurrentRouteMatch))
#42 /var/www/html/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\ViewEvent), 'kernel.view', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#44 /var/www/html/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(111): call_user_func(Array, Object(Symfony\Component\HttpKernel\Event\ViewEvent), 'kernel.view', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#45 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(186): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object(Symfony\Component\HttpKernel\Event\ViewEvent), 'kernel.view')
#46 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#47 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#48 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#49 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#50 /var/www/html/web/core/modules/big_pipe/src/StackMiddleware/ContentLength.php(32): Drupal\Core\StackMiddleware\ContentLength->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#51 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\big_pipe\StackMiddleware\ContentLength->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#52 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#53 /var/www/html/web/core/modules/ban/src/BanMiddleware.php(50): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#54 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\ban\BanMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#55 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#56 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#57 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#58 /var/www/html/web/core/lib/Drupal/Core/DrupalKernel.php(704): Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#59 /var/www/html/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#60 {main}

Steps to reproduce

Try to add group to cart.

Proposed resolution

Fix it.

Remaining tasks

Review it and commit it.

🐛 Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

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

Comments & Activities

Production build 0.69.0 2024