CartValidate and CartCheckout behavior after upgrade to Commerce 11

Vote:
 

Hi!

After upgrade to Commerce 11 the CartValidate and CartCheckout workflows behavies strange. Well at least the CartCheckout.

The CartValidate works fine and keeps my item in the cart, but after creating a purchase order I run the CartCheckout workflow which removes my items from the cart with this message:

Item X has been removed from the cart because there is not enough available quantity

The item has > 10 in stock but still gets removed.

If I create an order on site it works fine, but this is Klarna Checkout so our solution gets a push and we load the cart again from the push info adn creates the order. After loading the cart the maxumum quantity is 0 and there for the items gets removed. During the CartValidate the maximum quantity is 999 which is the correct value.

Any ideas?

/Kristoffer

#182451
Sep 19, 2017 15:08
Vote:
 

That's very strange. LineItem.MaxQuantity should be set in ValidateLineItemsActivity, which is run in CartValidate flow. Did you save the cart after running CartValidate?

#182453
Sep 19, 2017 16:22
Vote:
 

Yes, well we set it before creating the order in Klarna. When the push arrives from Klarna we do an OrderContext.Current.FindCarts to get the cart using the Klarna order id. Works fine. We then modify the cart and save it. Then we create an purchase order using the cart.SaveAsPurchaseOrder(); Works fine aswell. After that we run the CartCheckout workflow and then the item gets removed.

I have tried an ugly workaround. Before the workflow is run I do this:

var orderForm = cart.OrderForms[0];
foreach (LineItem lineItem in orderForm.LineItems)
{
      lineItem.MaxQuantity = 999;
}
cart.AcceptChanges();

Then the item doesn't get removed but instead we get:

Can not request inventory due to not enough quantity.

Another strange thing is that when I load the purchase order it has added an empty OrderForm, so the purchase order suddenly contains two OrderForms. And finally, the order in then Manager has no rows.

I am really confused!

/Kristoffer

#182456
Edited, Sep 19, 2017 17:04
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.