The module simply looks at the Add to cart form quantity field to check if it is within bounds. There is no prevention to continue adding the same item to a cart. If the quantity field in the add to cart form is disabled in order to have a default quantity of 1 the module will crash.
I did not create a patch to fix this because I need to create a module that also looks at existing items in the cart to eliminate the ability to continue adding the same item to the cart past an item limit.
The following code changes to commerce_product_minmax.module will fix the errors and it will run as intended. Inline comments should serffice. At about line 32...
if ($quantity === null) { // jch module did not account for add-to-cart form quantity being disabled for a default quantity of 1.
$quantity = '1';
}
if ($field) {
$quantity_range = $field->getvalue(); // Added this line to replace following line.
// This line causes an error... $quantity_range = $field->first()->getValue();
There also appears to be some dunsel code within function commerce_product_minmax_entity_insert(EntityInterface $entity) {
Comments
Comment #2
.jch commentedComment #4
davisbenCommitted to 8.x-1.x.