Problem/Motivation

We use a custom cart view that doesn't have a quantity field, and in this case commerce_stock_enforcement throws a PHP error at checkout when the item is out of stock:

TypeError: Drupal\Core\Form\FormState::setError(): Argument #1 ($element) must be of type array, null given, called in web/modules/contrib/commerce_stock/modules/enforcement/commerce_stock_enforcement.module on line 241 in Drupal\Core\Form\FormState->setError() (line 1118 of core/lib/Drupal/Core/Form/FormState.php).

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Comments

wxactly created an issue. See original summary.

wxactly’s picture

This patch fixes the bug.

wxactly’s picture

StatusFileSize
new818 bytes

Re-uploading #2 with fixed whitespace formatting

damienmckenna’s picture

Version: 8.x-1.1 » 8.x-1.x-dev
Status: Active » Needs review

Just ran into this problem on a site where we hide the product quantity as only one item can be added at a time.

guy_schneerson’s picture

Status: Needs review » Fixed

Thanks @wxactly Patch works and makes sense. Committed

Status: Fixed » Closed (fixed)

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