# Getting ShoppingCartInvalidException during place order

**URL:** <https://forum.litium.com/t/getting-shoppingcartinvalidexception-during-place-order/2042>\
**Category:** Questions\
**Created:** [May 4, 2021, 2:54pm UTC](https://forum.litium.com/t/getting-shoppingcartinvalidexception-during-place-order/2042 "2021-05-04T14:54:17Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![marten.olofsson](https://avatars.discourse-cdn.com/v4/letter/m/7cd45c/32.png) [@marten.olofsson](https://forum.litium.com/u/marten.olofsson)\
**Post date:** [May 4, 2021, 2:54pm UTC](https://forum.litium.com/t/getting-shoppingcartinvalidexception-during-place-order/2042/1 "2021-05-04T14:54:17Z")

</div>

Hi,

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]_

---

<div class="post-metadata">

**Author:** ![NilsN](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/nilsn/32/302_2.png) [@NilsN](https://forum.litium.com/u/NilsN)\
**Post date:** [May 5, 2021, 7:51am UTC](https://forum.litium.com/t/getting-shoppingcartinvalidexception-during-place-order/2042/2 "2021-05-05T07:51:59Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![marten.olofsson](https://avatars.discourse-cdn.com/v4/letter/m/7cd45c/32.png) [@marten.olofsson](https://forum.litium.com/u/marten.olofsson)\
**Post date:** [May 5, 2021, 11:41am UTC](https://forum.litium.com/t/getting-shoppingcartinvalidexception-during-place-order/2042/3 "2021-05-05T11:41:09Z")

</div>

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](https://forum.litium.com/uploads/short-url/h4EAwSzDjJfYKhaLmpRwKV3umCH.txt) (15.7 KB)

---

<div class="post-metadata">

**Author:** ![marten.olofsson](https://avatars.discourse-cdn.com/v4/letter/m/7cd45c/32.png) [@marten.olofsson](https://forum.litium.com/u/marten.olofsson)\
**Post date:** [May 6, 2021, 9:50am UTC](https://forum.litium.com/t/getting-shoppingcartinvalidexception-during-place-order/2042/4 "2021-05-06T09:50:34Z")

</div>

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.

//Mårten

---

<div class="post-metadata">

**Author:** ![NilsN](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/nilsn/32/302_2.png) [@NilsN](https://forum.litium.com/u/NilsN)\
**Post date:** [May 6, 2021, 11:25am UTC](https://forum.litium.com/t/getting-shoppingcartinvalidexception-during-place-order/2042/5 "2021-05-06T11:25:37Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/litium/original/1X/12eddac3b8b661de1db86af10ac8151b571e6fb9.png) [@system](https://forum.litium.com/u/system)\
**Post date:** [June 3, 2021, 11:26am UTC](https://forum.litium.com/t/getting-shoppingcartinvalidexception-during-place-order/2042/6 "2021-06-03T11:26:30Z")

</div>

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