Problem/Motivation
after the commit of 2.x-dev #92d9ac38 on commerce core, this module throws the following error when the add to cart button is clicked.
The website encountered an unexpected error. Please try again later.
TypeError: Drupal\commerce\Context::__construct(): Argument #1 ($customer) must be of type Drupal\Core\Session\AccountInterface, null given, called in /Users/loze/Sites/XXXXX/web/modules/contrib/commerce/modules/cart/src/Form/AddToCartForm.php on line 248 in Drupal\commerce\Context->__construct() (line 58 of modules/contrib/commerce/src/Context.php).
Drupal\commerce\Context->__construct(NULL, Object) (Line: 248)
Drupal\commerce_cart\Form\AddToCartForm->prepareOrderItem(Object) (Line: 232)
Drupal\commerce_cart\Form\AddToCartForm->buildEntity(Array, Object) (Line: 186)
Drupal\Core\Entity\ContentEntityForm->validateForm(Array, Object)
call_user_func_array(Array, Array) (Line: 82)
Drupal\Core\Form\FormValidator->executeValidateHandlers(Array, Object) (Line: 275)
Drupal\Core\Form\FormValidator->doValidateForm(Array, Object, 'commerce_order_item_pado_add_to_cart_form_commerce_product_365052') (Line: 118)
Drupal\Core\Form\FormValidator->validateForm('commerce_order_item_pado_add_to_cart_form_commerce_product_365052', Array, Object) (Line: 593)
Drupal\Core\Form\FormBuilder->processForm('commerce_order_item_pado_add_to_cart_form_commerce_product_365052', Array, Object) (Line: 325)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 58)
Drupal\commerce_pado\PadoLazyBuilders->addToCartWithAddOnsForm('365052', 'full', 1, 'field_addon_product', 1)
call_user_func_array(Array, Array) (Line: 101)
Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #lazy_builder callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was %s. See https://www.drupal.org/node/2966725', 'exception', 'Drupal\Core\Render\Element\RenderCallbackInterface') (Line: 788)
Drupal\Core\Render\Renderer->doCallback('#lazy_builder', Array, Array) (Line: 353)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 446)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 204)
Drupal\Core\Render\Renderer->render(Array) (Line: 479)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 68)
__TwigTemplate_9b5fc598523327d59509e5acb5e77e78->doDisplay(Array, Array) (Line: 405)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 378)
Twig\Template->display(Array) (Line: 390)
Twig\Template->render(Array) (Line: 55)
twig_render_template('themes/custom/crew/templates/field/field.html.twig', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('field', Array) (Line: 433)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 446)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 446)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 204)
Drupal\Core\Render\Renderer->render(Array) (Line: 479)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 47)
__TwigTemplate_492d4cfd2053dae182822bab4ee9afbd->doDisplay(Array, Array) (Line: 405)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 378)
Twig\Template->display(Array) (Line: 390)
Twig\Template->render(Array) (Line: 55)
twig_render_template('themes/custom/crew/templates/commerce/commerce-product--registered-event--full.html.twig', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('commerce_product', Array) (Line: 433)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 204)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 242)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 580)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 243)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 132)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
call_user_func(Array, Object, 'kernel.view', Object) (Line: 142)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.view') (Line: 174)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 81)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 209)
Drupal\cleantalk\EventSubscriber\BootSubscriber->handle(Object, 1, 1) (Line: 49)
Asm89\Stack\Cors->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 718)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
I believe this is because of the changes to AddToCartForm.php in this commit.
https://git.drupalcode.org/project/commerce/-/commit/92d9ac383f1ce7c6038...
using commerce cores addToCartForm works. but using the add to cart form supplied by this module breaks with this error.