public static function OrderItemInlineForm::buildOrderItem in Commerce Core 8.2
Entity builder: populates the order item title from the purchased entity and set the reference to the order being edited.
Parameters
string $entity_type: The entity type identifier.
\Drupal\commerce_order\Entity\OrderItemInterface $order_item: The order item.
array $form: The complete form array.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
File
- modules/
order/ src/ Form/ OrderItemInlineForm.php, line 67
Class
- OrderItemInlineForm
- Defines the inline form for order items.
Namespace
Drupal\commerce_order\FormCode
public static function buildOrderItem($entity_type, OrderItemInterface $order_item, array $form, FormStateInterface $form_state) {
$purchased_entity = $order_item
->getPurchasedEntity();
if ($order_item
->isNew()) {
if ($purchased_entity) {
$order_item
->setTitle($purchased_entity
->getOrderItemTitle());
}
$order_item
->set('order_id', $form_state
->getFormObject()
->getEntity());
}
}