Possible bug related to migrate of carts

Mari Jørgensen
Member since: 2003
 

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?

#188761 Mar 02, 2018 11:21
  • Quan Mai
    Member since: 2011
     

    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.

    #188764 Mar 02, 2018 11:59
  • Mari Jørgensen
    Member since: 2003
     

    In my class that inherits from ProfileMigrator:

    public override void MigrateCarts(Guid anonymousId)
            {
                base.MigrateCarts(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.

    #188768 Mar 02, 2018 13:28
  • Quan Mai
    Member since: 2011
     

    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.

    #188769 Mar 02, 2018 13:43
  • Mari Jørgensen
    Member since: 2003
     

    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:

    cart.GetFirstShipment()
    {EPiServer.Commerce.Order.Internal.SerializableShipment}
        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
    #188932 Mar 07, 2018 9:54
  • Quan Mai
    Member since: 2011
     

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

    #188942 Mar 07, 2018 11:51
  • Mari Jørgensen
    Member since: 2003
     

    Thanks, Quan!

    #188980 Mar 08, 2018 9:09
  • Quan Mai
    Member since: 2011
     

    No, thank You! Please keep the reports coming!

    #188982 Mar 08, 2018 9:13
  • Quan Mai
    Member since: 2011
     

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

    #189307 Mar 15, 2018 8:58