Litium 7 accelerator shopping cart organization

Where is PersonStorage.SelectedOrganization applied to the shoppingcart in litium 7 accelerator?
We have a problem persons connected to multiple organization get wrong organization after the first order after logging in. Looks like selected organization isn’t used after first order placed and Cart.Clear() is executed. After that organization on the shoppingcart is set to current person first organization even if PersonStorageSelectedOrganization is still correct.

Litium version: 7.3

I did some testing and can confirm the behavior you’re describing. After the cart is reset the OrganizationId is set to the first value and the next time it calls _moduleECommerce.CheckoutFlow.AddOrEditCustomerInfo it doesn’t set the organization to the id you pass to the method. Could you please report it as a bug on Docs so the product team can look into it?

Perhaps you could create an attribute that checks if the current organization id on the order carrier matches the one in PersonStorage, and if it doesn’t you update it. Something like below. I tested by adding it as an attribute on the Index action for CheckoutController.

public class EnsureSelectedOrganizationFilterAttribute : ActionFilterAttribute
{
	private static readonly CartAccessor _cartAccessor = IoC.Resolve<CartAccessor>();

	public override void OnResultExecuted(ResultExecutedContext filterContext)
	{
		var orderCarrier = _cartAccessor.Cart.OrderCarrier;

		if (orderCarrier != null)
		{
			var organizationSystemId = orderCarrier.CustomerInfo.OrganizationID;
			var currentSelectedOrganization = PersonStorage.CurrentSelectedOrganization;

			if (organizationSystemId != currentSelectedOrganization?.SystemId)
			{
				PersonStorage.CurrentSelectedOrganization = currentSelectedOrganization;
			}
		}
	}
}

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