How does the price/campaign calculation account for current selected organization?

It seems like a person connected to multiple organizations will get access to the prices from any of those organizations, even if it is not the org they selected on sign in.

Example:
A person p1 has Orderlaggare role on two organizations, org1 and org2. I add a campaign with condition “User belongs to organization → org1”. I sign in to the store as person p1 and choose organization org2 at the sign in. The campaign is still visible for person p1, even though the campaign is not valid for the selected organization. Is this a bug or is it the expected behavior?

Is there any easy way to override this or should we work with campaigns in a different way?

Litium version: 7.6.1

This is a bug but it should be fixed in the Litium 7.2 accelerator release so even if you have Litium 7.6.1 you can have this bug if the accelerator are older.

45142 Best price used. Not best price for selected organisation

Thanks, seems similar but not quite the same. Price lists work as expected in my version but I still get this behavior on campaigns that should be limited to one organization.

Can’t find any existing bug reports for this so I created one: 59826

Sorry i didnt read your example good enough. The condition “Use belongs to organization” doesn’t do what you want it to to. It checks if current user belongs to a specific organization.

protected override IEnumerable<Guid> Evaluate(ConditionArgs conditionArgs) => conditionArgs.UsersOrganizationIDs.Where<Guid>((Func<Guid, bool>) (organizationID => this.m_data.OrganizationIDs.Contains(organizationID)));

Current selected organization is a accelerator feature so the litium campaigns doesnt know about that. If you want campaign condition “Current selected organization is” i think to need to build that as a custom condition.

Hi,

I might be missing something but why does the price list lookup check for current selected organization, while campaign lookup does not?

Feels like this should be a fairly common scenario for b2b customers.

Current organization connected pricelists is used because it is implemented a check for that in the Litium.Accelerator.Mvc.Methods.PriceListCalculator in the accelerator project code.

But I agree that this is not uncommon scenario

Here’s an example of how to implement this as a custom condition in Litium 7. It re-uses the same panel as the default condition. You can add a name by creating a resource file as specified here with the key CurrentSelectedOrganizationConditionName.

Note for potential upgrades: Litium 8 does not support custom conditions and the product team are looking into how to solve this as part of the bug report.

using System;
using System.Collections.Generic;
using System.Linq;
using Litium.Foundation.Modules.ECommerce.Plugins.Campaigns.ConditionTypes;
using System.Text;
using Litium.Customers;
using Litium.Foundation.Modules.ECommerce;
using Litium.Foundation.Modules.ECommerce.Plugins.Campaigns;
using Litium.Accelerator.Utilities;
using Litium.Foundation.Modules.ECommerce.Plugins.Campaigns.Conditions;

namespace Litium.Accelerator.Custom
{
	/// <summary>
	/// User belongs to organization condition.
	/// </summary>
	public class CurrentSelectedOrganizationCondition : UserConditionType
	{

		private const string PATH = "~/Litium/ECommerce/WebUserControls/Conditions/UserBelongsToOrganizationConditionControl.ascx";
		private UserBelongsToOrganizationCondition.Data m_data;

		/// <summary>
		/// Initializes the specified data.
		/// </summary>
		/// <param name="data">The data.</param>
		protected override void Initialize(object data)
		{
			base.Initialize(data);
			m_data = (UserBelongsToOrganizationCondition.Data)data;
		}

		/// <summary>
		/// Evaluates the specified condition.
		/// </summary>
		/// <param name="conditionArgs">The condition args.</param>
		/// <returns></returns>
		protected override IEnumerable<Guid> Evaluate(ConditionArgs conditionArgs)
		{
			var personStorage = IoC.Resolve<PersonStorage>();

			return personStorage?.CurrentSelectedOrganization != null ?
				m_data.OrganizationIDs.Where(x => x.Equals(personStorage.CurrentSelectedOrganization.SystemId))
				: Enumerable.Empty<Guid>();
		}

		/// <summary>
		/// Gets the panel path.
		/// </summary>
		/// <value>The panel path.</value>
		public override string PanelPath { get { return PATH; } }

		/// <summary>
		/// Gets the description.
		/// </summary>
		/// <param name="languageID">The language ID.</param>
		/// <returns></returns>
		public override string GetDescription(Guid languageID)
		{
			StringBuilder sb = new StringBuilder();
			if (m_data != null)
			{
				sb.Append(ModuleECommerce.Instance.Strings.GetValue("UserBelongsToOrganizationConditionDescription", languageID, true));
				foreach (Guid item in m_data.OrganizationIDs)
				{
					Organization organization = IoC.Resolve<OrganizationService>().Get(item);
					if (organization != null)
					{
						sb.Append(Environment.NewLine);
						sb.Append(organization.Name);
					}
				}
			}
			else
			{
				sb.Append(base.GetDescription(languageID));
			}
			return sb.ToString();
		}
	}
}
1 Like

Thanks Nils, I’ll try that out if the customer wants us to proceed :slight_smile:

Regards,
Felix

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