Try our conversational search powered by Generative AI!

Possible bug related to migrate of carts


We are running Episerver Commerce version 11.2.4 and we are using "new" order api.

When investigating a reported issue related to missing tax on carts after login, I discovered that shipment is null after cart migrate (ProfileMigrator). 

To clearify the process:

  1. An anonymous user adds an item to the cart
  2. Since the site is Norway only, we add shipment to cart as part of addToCart operation
  3. The user logs in and navigates to checkout
  4. Item in cart is missing taxes

I solved it my overriding ProfileMigrator and adding shipment in MigrateCarts method.

This can be considered a bug, right?

Mar 02, 2018 11:21

Hey, it's not "new" any more! It's the norm these days. 

Can you post how did you "fix" it - the code?

We actually merge/add the shipments in cart, but I think you would have to recalculate the taxes after merging. The rule is simple - you have changes to item(s), you would have to re-calculate the taxes.

Mar 02, 2018 11:59

In my class that inherits from ProfileMigrator:

public override void MigrateCarts(Guid anonymousId)
            // get cart for current user and try to save cart
            var cart = _cartService.LoadCart(_cartService.DefaultCartName);
            if (cart != null)
                _cartHelper.EnsureStoreShipmentAddress(cart, _orderGroupFactory);

The EnsureStoreShipmentAddress checks if cart has shipment and shipmentAdress - and adds it if empty.

Mar 02, 2018 13:28

So were the taxes there after the user logs in?

Are there any shipments in the cart after merging?

As I said you would probably need to re-calculate the taxes.

To be completely honest I think this might be a bug before, but should not a problem now at least.

Mar 02, 2018 13:43

Sorry for the late response, been occupied with different stuff.

What happens is that shipment is there, but there is no shipping address no shipping address means 0 taxes:

    LineItems: Count = 1
    OperationKeys: Count = 0
    OrderShipmentStatus: AwaitingInventory
    PickListId: null
    Properties: Count = 0
    ShipmentDiscount: 0
    ShipmentId: -13
    ShipmentTrackingNumber: null
    ShippingAddress: null
    ShippingMethodId: {00000000-0000-0000-0000-000000000000}
    ShippingMethodName: null
    WarehouseCode: null
Mar 07, 2018 9:54

Fair enough.I created a bug (COM-6730) and will let triage team handle it.

Mar 07, 2018 11:51

Thanks, Quan!

Mar 08, 2018 9:09

No, thank You! Please keep the reports coming!

Mar 08, 2018 9:13

The bug is now fixed (by your "old" friend, Viet Anh) 

Mar 15, 2018 8:58
* 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.