Dynamically update line item in Commerce 2 I'm currently trying to adjust the line items in a particular cart/order after an event is triggered.

I've got:

use craft\commerce\Plugin as CommercePlugin;

$this-&gt;requirePostRequest();
$request = Craft::$app-&gt;getRequest();

$cart = CommercePlugin::getInstance()-&gt;getCarts()-&gt;getCart(true);

$lineItem = CommercePlugin::getInstance()-&gt;getLineItems()-&gt;getLineItemById($cart-&gt;lineItems[0]-&gt;id);

$lineItem-&gt;price = 100.0000;
$lineItem-&gt;salePrice = 100.0000;
$lineItem-&gt;qty = 1;
$lineItem-&gt;note = '';

$cart-&gt;addLineItem($lineItem);

$cart-&gt;email = $request-&gt;getParam('orderEmail');

if (!Craft::$app-&gt;getElements()-&gt;saveElement($cart)) {
   return false;
}


But this seems to not do anything, except update $lineItem and not update the line item when the cart is then saved.
Turns out I just replace:

$cart-&gt;addLineItem($lineItem);

With:

CommercePlugin::getInstance()-&gt;getLineItems()-&gt;saveLineItem($lineItem, false);