public function LineItems::addLineItem in Ubercart 8.4
Order pane submit callback: Add a line item to an order.
File
- uc_order/
src/ Plugin/ Ubercart/ OrderPane/ LineItems.php, line 176
Class
- LineItems
- View and modify an order's line items.
Namespace
Drupal\uc_order\Plugin\Ubercart\OrderPaneCode
public function addLineItem($form, FormStateInterface $form_state) {
$order =& $form_state
->get('order');
$type = $form_state
->getValue('li_type_select');
$line_item_manager = \Drupal::service('plugin.manager.uc_order.line_item');
uc_order_line_item_add($order
->id(), $type, $line_item_manager
->getDefinition($type)['title'], 0);
$order->line_items = $order
->getLineItems();
$form_state
->setRebuild();
}