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;

$request = Craft::$app->getRequest();

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

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

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


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

if (!Craft::$app->getElements()->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.

  • 1
    Any errors on the cart after saving? Mar 15, 2019 at 16:36
  • @LukeHolder No errors, and the flash just returns "Cart Updated"
    – Jason Mayo
    Mar 19, 2019 at 10:59

1 Answer 1


Turns out I just replace:



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

  • is there a way to remove a line items from Plugin instance? Apr 11 at 21:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.