Skip to content
Snippets Groups Projects
Commit c6ebad84 authored by J P's avatar J P Committed by Jonathan Sacksick
Browse files

Issue #2890837 by czigor, loze: Order item type being ignored by the widget.

parent 9f6b91d9
No related branches found
No related tags found
1 merge request!235Issue #3115150 by mbovan: Submitting add to cart form with empty quantity...
Pipeline #69948 passed
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace Drupal\commerce_order\Form; namespace Drupal\commerce_order\Form;
use Drupal\commerce_order\Entity\OrderItemType;
use Drupal\Component\Datetime\TimeInterface; use Drupal\Component\Datetime\TimeInterface;
use Drupal\Core\Datetime\DateFormatterInterface; use Drupal\Core\Datetime\DateFormatterInterface;
use Drupal\Core\Entity\ContentEntityForm; use Drupal\Core\Entity\ContentEntityForm;
...@@ -60,6 +61,16 @@ class OrderForm extends ContentEntityForm { ...@@ -60,6 +61,16 @@ class OrderForm extends ContentEntityForm {
$order = $this->entity; $order = $this->entity;
$form = parent::form($form, $form_state); $form = parent::form($form, $form_state);
// Narrow down order item types for the complex IEF widget.
if (isset($form['order_items']['widget']['actions'], $form['order_items']['widget']['actions']['bundle']) && !empty($form['order_items']['widget']['actions']['bundle']['#options'])) {
foreach ($form['order_items']['widget']['actions']['bundle']['#options'] as $order_item_type_id => $label) {
$order_item_type = OrderItemType::load($order_item_type_id);
if ($order_item_type->getOrderTypeId() !== $order->bundle()) {
unset($form['order_items']['widget']['actions']['bundle']['#options'][$order_item_type_id]);
}
}
}
$form['#tree'] = TRUE; $form['#tree'] = TRUE;
$form['#theme'] = 'commerce_order_edit_form'; $form['#theme'] = 'commerce_order_edit_form';
$form['#attached']['library'][] = 'commerce_order/form'; $form['#attached']['library'][] = 'commerce_order/form';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment