Describe your bug or feature request.
Currently the BaseFieldDefinitions of the OrderItem entity do not make it possible to add the adjustments to the Form Mode.
This means that as an admin, it's not possible to see or edit adjustments applied at the Line Item level.
$fields['adjustments'] = BaseFieldDefinition::create('commerce_adjustment')
->setLabel(t('Adjustments'))
->setRequired(FALSE)
->setCardinality(BaseFieldDefinition::CARDINALITY_UNLIMITED)
->setDisplayConfigurable('form', FALSE)
->setDisplayConfigurable('view', TRUE);
If a bug, provide steps to reproduce it from a clean install.
1. Create OrderItem, add just Adjustment, add to cart
$orderItem = OrderItem::create([
'type' => 'default',
'quantity' => 1,
'data' => [],
'purchased_entity' => $product,
'title' => 'Test',
'unit_price' => $product->getPrice(),
]);
$adjustment = new Adjustment([
'type' => 'custom',
'amount' => new Price('10', 'GBP'),
'label' => $this->t('Test Adjustment'),
'source_id' => 'my_custom_source_id',
'included' => FALSE,
'locked' => TRUE,
]);
$orderItem->addAdjustment($adjustment);
$orderItem->save();
$this->cartManager->addOrderItem($cart, $orderItem, FALSE);
2. View cart in the Admin, there's no option to modify to add adjustments at the line item level, and no option to add the adjustments field to the UI.


It seems like it would be fairly easy just to change this field to allow Developers to place it on the Edit screens if desired?
Comments
Comment #2
mattjones86For anyone else that needs to solve this, here's how I've done it:
Comment #3
jsacksick commentedProbably doesn't hurt to make this change in core without displaying it by default so anyone wanting to do this could.
Comment #4
jsacksick commentedComment #6
jsacksick commentedWent ahead and committed the fix, thanks!
Comment #8
mattjones86Great, thanks!