Getting ShoppingCartInvalidException during place order


We are migrating to a new checkout page and getting the exception "ShoppingCartInvalidException " with the message “OrderRowNotIncludedInAValidDelivery” during shopping cart validation in the klarna callback. We have examined the order carriers on disc and it seems that the deliveryId on the orderRows is not matching the seleced delivery.

It’s this code (decompiled litium code) that is throwing the exception:

foreach (OrderRowCarrier orderRow1 in carrier.OrderRows)
  OrderRowCarrier orderRow = orderRow1;
  if (orderRow.DeliveryID == Guid.Empty)
    throw new ShoppingCartItemInvalidException(ShoppingCartItemInvalidErrorCode.OrderRowNotIncludedInAValidDelivery);
  DeliveryCarrier deliveryCarrier = carrier.Deliveries.FirstOrDefault<DeliveryCarrier>((Func<DeliveryCarrier, bool>) (x => x.ID == orderRow.DeliveryID));
  if (deliveryCarrier == null || deliveryCarrier.OrderID != orderRow.OrderID)
    throw new ShoppingCartItemInvalidException(ShoppingCartItemInvalidErrorCode.OrderRowNotIncludedInAValidDelivery);

Do someone have any pointers for how an orderCarrier could end up in such a broken state? We have tried to reproduce the issue without any luck. It’s not happening all the time, only sometimes.

Litium version: [7.6.3]


Could you share an order as its written to disk? (Anonymized)
Are you making changes to the delivery in any way? Have you made sure you’re updating the order on disk every time?
Do you have a call stack for the error?
Do you make any changes to the order after it’s sent to Klarna? Order id, for example.
Are the deliveries on the OrderCarrier connect to the correct order?

Hi Nils! I attached an example of an incorrect order (on disc).

Yes we are making changes to the order carrier when the deliverymethod is changed but it’s updated on disc everytime we send it to klarna.

incorrect.txt (15.7 KB)

Hi again Nils,

we have managed to figure out why this was happening. The issue was when we were removing items from the cart a delivery method was added to the order carrier (which was a little unexpected). And when entering the checkout we never added the deliverymethod to the checkoutflow. When doing so everything worked as expected.


1 Like

Happy to hear you solved it, and thank you for sharing what the issue was!


This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.