Problem/Motivation

AssertionError: Cannot load the "commerce_product_variation" entity with NULL ID. in assert() (line 244 of D:\Projects\antiqa\web\core\lib\Drupal\Core\Entity\EntityStorageBase.php).
and line that trying to load the entity is in line 135 commerce_stock\modules\enforcement\commerce_stock_enforcement.module.

Steps to reproduce

when use ajax add to cart form with commerce_variation_cart_form and commerce_stock_enforcement, so install commerce_variation_cart_form, ajax_add_to_cart, commerce_stock_enforcement modules and try the ajax add to cart feature.

Proposed resolution

a patch to resolve the purchased entity from form entity if not set in form state values.

Remaining tasks

community to review patch.

Comments

Mohamed Nabawy created an issue. See original summary.

mohamed nabawy’s picture

mohamed nabawy’s picture

mohamed nabawy’s picture

randalv’s picture

Version: 8.x-1.1 » 8.x-1.x-dev
Status: Needs review » Reviewed & tested by the community

I have had this issue as well, thank you for the patch. It seems to work for me.

I had my doubts about retrieving the entity from the form object, but I suppose in the end it makes sense to do it this way.

guy_schneerson’s picture

Status: Reviewed & tested by the community » Fixed

Thanks @Mohamed Nabawy for the patch and @RandalV for testing.

Status: Fixed » Closed (fixed)

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