Submitting empty quantity value ends up in InvalidArgumentException

Created on 12 July 2023, 12 months ago
Updated 17 November 2023, 8 months ago

When a user removes quantity from the quantity field and submits the form by using the Enter key, an unhandled InvalidArgumentException is thrown. This should probably be handled and a form error message should be displayed upon page reload. Stack trace:

InvalidArgumentException: The provided value "" is not a numeric value. in Drupal\commerce_price\Calculator::assertNumberFormat() (line 261 of modules\commerce\modules\price\src\Calculator.php).
Drupal\commerce_price\Calculator::multiply() (Line: 155)
Drupal\commerce_price\Price->multiply() (Line: 365)
Drupal\commerce_order\Entity\OrderItem->recalculateTotalPrice() (Line: 135)
Drupal\commerce_order\Entity\OrderItem->setUnitPrice() (Line: 295)
Drupal\commerce_cart\Form\AddToCartForm->prepareOrderItem() (Line: 277)
Drupal\commerce_cart\Form\AddToCartForm->buildEntity() (Line: 186)
Drupal\Core\Entity\ContentEntityForm->validateForm()
call_user_func_array() (Line: 82)
Drupal\Core\Form\FormValidator->executeValidateHandlers() (Line: 275)
Drupal\Core\Form\FormValidator->doValidateForm() (Line: 118)
Drupal\Core\Form\FormValidator->validateForm() (Line: 591)
Drupal\Core\Form\FormBuilder->processForm() (Line: 323)
Drupal\Core\Form\FormBuilder->buildForm() (Line: 97)
Drupal\commerce_product\ProductLazyBuilders->addToCartForm()
call_user_func_array() (Line: 101)
Drupal\Core\Render\Renderer->doTrustedCallback() (Line: 788)
Drupal\Core\Render\Renderer->doCallback() (Line: 353)
Drupal\Core\Render\Renderer->doRender() (Line: 446)
Drupal\Core\Render\Renderer->doRender() (Line: 204)
Drupal\Core\Render\Renderer->render() (Line: 479)
Drupal\Core\Template\TwigExtension->escapeFilter() (Line: 67)
__TwigTemplate_0887ee743ac12f9dab23e01187d12e8c->doDisplay() (Line: 405)
Twig\Template->displayWithErrorHandling() (Line: 378)
Twig\Template->display() (Line: 390)
Twig\Template->render() (Line: 55)
twig_render_template() (Line: 384)
Drupal\Core\Theme\ThemeManager->render() (Line: 433)
Drupal\Core\Render\Renderer->doRender() (Line: 204)
Drupal\Core\Render\Renderer->render() (Line: 479)
Drupal\Core\Template\TwigExtension->escapeFilter() (Line: 97)
__TwigTemplate_1ad1c4c86e33858ff4cdbdc930e22b3c->doDisplay() (Line: 405)
Twig\Template->displayWithErrorHandling() (Line: 378)
Twig\Template->display() (Line: 390)
Twig\Template->render() (Line: 55)
twig_render_template() (Line: 384)
Drupal\Core\Theme\ThemeManager->render() (Line: 433)
Drupal\Core\Render\Renderer->doRender() (Line: 204)
Drupal\Core\Render\Renderer->render() (Line: 242)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 580)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 243)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare() (Line: 132)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse() (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray()
call_user_func() (Line: 142)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() (Line: 174)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 81)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 58)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 50)
Drupal\ban\BanMiddleware->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 23)
Stack\StackedHttpKernel->handle() (Line: 718)
Drupal\Core\DrupalKernel->handle() (Line: 19)
🐛 Bug report
Status

Closed: duplicate

Version

2.36

Component

Product

Created by

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.69.0 2024