Error on add_to_cart manage form display page

Created on 25 July 2024, 5 months ago

Hello! Thank you for this great project!

Drupal 10.3.
On page manage "Add to cart" form display /admin/commerce/config/order-item-types/default/edit/form-display/add_to_cart
I've got the error:

The website encountered an unexpected error. Try again later.

TypeError: call_user_func_array(): Argument #1 ($callback) must be a valid callback, no array or string given in call_user_func_array() (line 72 of core/modules/field_ui/src/Element/FieldUiTable.php).
Drupal\field_ui\Element\FieldUiTable::tablePreRender()
call_user_func_array() (Line: 113)
Drupal\Core\Render\Renderer->doTrustedCallback() (Line: 870)
Drupal\Core\Render\Renderer->doCallback() (Line: 432)
Drupal\Core\Render\Renderer->doRender() (Line: 504)
Drupal\Core\Render\Renderer->doRender() (Line: 248)
Drupal\Core\Render\Renderer->render() (Line: 238)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 638)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 231)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare() (Line: 128)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse() (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray()
call_user_func() (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() (Line: 186)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle() (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 741)
Drupal\Core\DrupalKernel->handle() (Line: 19)

I tried some variants:
When create order_item_type on page /admin/commerce/config/order-item-types and didn't set form field 'Purchasable entity type'
(will be empty) I've got this error.
When set in this field "Product Variation" it works perfectly.
Please disable for user input this field as empty. Or something else... it's confusing and time consuming.

🐛 Bug report
Status

Active

Version

2.39

Component

Commerce

Created by

🇧🇾Belarus VasiliyRepin Minsk

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @VasiliyRepin
  • 🇮🇱Israel jsacksick

    Managed to reproduce this, somehow it seems that the code in OrderItem::bundleFieldDefinitions() doesn't work as expected and especially these lines of code:

    $fields['purchased_entity']->setDisplayOptions('form', [
            'region' => 'hidden',
          ]);

    This could be a Drupal core bug... Can't figure out exactly what's wrong yet, will keep digging.

  • 🇮🇱Israel jsacksick

    Removing $fields['purchased_entity']->setDisplayConfigurable('form', FALSE); fixes the crash, but that then makes the field configurable even though we shouldn't be able to add it to the form since there is no purchasable entity type set, so the field can't work properly...

  • I'm running into this same issue. Any updates?

  • 🇺🇸United States abenguyen

    Also running into this issue..

    Drupal 10.3.6
    PHP 8.2

Production build 0.71.5 2024