Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
e6c429d
Control Live Discount Behavior for Users, User Groups, and Anonymous …
DWDBE Oct 20, 2025
69d7047
Add IsLivePricesDisabled to User Groups
DWDBE Oct 24, 2025
5b9be13
update with last master
DWDBE May 13, 2026
fccf247
Apply suggestions from code review
DWDBE May 13, 2026
cf13882
fix versions
DWDBE May 13, 2026
216ea3e
Potential fix for pull request finding
DWDBE May 13, 2026
bd1e6fa
fix build
DWDBE May 13, 2026
11b3eb5
Apply suggestions from code review
DWDBE May 15, 2026
df150bb
code review comments
DWDBE May 18, 2026
4b97e1c
Fix caching for ErpControlsDiscount
DWDBE May 18, 2026
90b5b82
Potential fix for pull request finding
DWDBE May 18, 2026
297a256
improve performance
DWDBE May 18, 2026
ac70528
Merge branch 'dbe/25694-Control-Live-Discount-Behavior-for-Users,-Use…
DWDBE May 18, 2026
0eb7b70
Potential fix for pull request finding
DWDBE May 18, 2026
ec392e6
code review
DWDBE May 18, 2026
8223cb2
Merge branch 'dbe/25694-Control-Live-Discount-Behavior-for-Users,-Use…
DWDBE May 18, 2026
13c76c8
Potential fix for pull request finding
DWDBE May 18, 2026
7d4e237
Potential fix for pull request finding
DWDBE May 18, 2026
faaf2f4
make api public
DWDBE May 18, 2026
6e17079
fix comments
DWDBE May 18, 2026
c0ee7a1
fix comments
DWDBE May 18, 2026
28de87f
Potential fix for pull request finding
DWDBE May 18, 2026
fb6ed5f
Potential fix for pull request finding
DWDBE May 18, 2026
38c38d9
comments fixes
DWDBE May 18, 2026
fc22fbd
Merge branch 'dbe/25694-Control-Live-Discount-Behavior-for-Users,-Use…
DWDBE May 18, 2026
08f6211
Potential fix for pull request finding
DWDBE May 19, 2026
b3c08cb
Potential fix for pull request finding
DWDBE May 19, 2026
57805a1
fix comments
DWDBE May 19, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dynamicweb" Version="10.4.0" />
<PackageReference Include="Dynamicweb.Core" Version="10.4.0" />
<PackageReference Include="Dynamicweb.DataIntegration" Version="10.4.0" />
<PackageReference Include="Dynamicweb.Ecommerce" Version="10.4.0" />
<PackageReference Include="Dynamicweb" Version="10.21.5" />
<PackageReference Include="Dynamicweb.Core" Version="10.21.5" />
<PackageReference Include="Dynamicweb.DataIntegration" Version="10.21.5" />
<PackageReference Include="Dynamicweb.Ecommerce" Version="10.21.5" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Dynamicweb.Ecommerce.DynamicwebLiveIntegration\Dynamicweb.Ecommerce.DynamicwebLiveIntegration.csproj" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Dynamicweb.Core;
using Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Connectors;
using Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Extensions;
using Dynamicweb.Frontend;

namespace Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Configuration
Expand Down Expand Up @@ -105,7 +106,7 @@ public static bool IsLazyLoadingForProductInfoEnabled(Settings settings)
{
return Global.IsIntegrationActive(settings) && settings.EnableLivePrices && Connector.IsWebServiceConnectionAvailable(settings, SubmitType.Live)
&& (settings.LiveProductInfoForAnonymousUsers || Helpers.GetCurrentExtranetUser() != null)
&& (Helpers.GetCurrentExtranetUser() == null || !Helpers.GetCurrentExtranetUser().IsLivePricesDisabled)
&& (Helpers.GetCurrentExtranetUser() == null || !Helpers.GetCurrentExtranetUser().IsLiveIntegrationPricesDisabled())
&& settings.LazyLoadProductInfo;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,5 +333,11 @@ public interface ISettings
/// Gets or sets a value that determines the max number of products on each live request.
/// </summary>
int MaxProductsPerRequest { get; set; }

/// <summary>
/// When enabled anonymous users will receive discounts calculated by DynamicWeb instead of retrieving them from the ERP via Live Integration
/// </summary>
/// <value><c>true</c> if [disable ERP discounts calculation for anonymous users]; otherwise, <c>false</c>.</value>
public bool DisableErpDiscountsForAnonymousUsers { get; set; }
Comment thread
DWDBE marked this conversation as resolved.
Outdated
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,12 @@ public string InstanceName
/// </summary>
public bool MakeRetryForLiveProductInformation { get; set; }

/// <summary>
/// When enabled anonymous users will receive discounts calculated by DynamicWeb instead of retrieving them from the ERP via Live Integration
/// </summary>
/// <value><c>true</c> if [disable ERP discounts calculation for anonymous users]; otherwise, <c>false</c>.</value>
public bool DisableErpDiscountsForAnonymousUsers { get; set; }
Comment thread
DWDBE marked this conversation as resolved.

#endregion Users parameters

#region Notifications parameters
Expand Down Expand Up @@ -463,6 +469,7 @@ public static void UpdateFrom(ISettings source, ISettings target)
target.OrderStateAfterExportFailed = source.OrderStateAfterExportFailed;
target.SkipLedgerOrder = source.SkipLedgerOrder;
target.ErpControlsDiscount = source.ErpControlsDiscount;
target.DisableErpDiscountsForAnonymousUsers = source.DisableErpDiscountsForAnonymousUsers;
target.ErpControlsShipping = source.ErpControlsShipping;
target.ErpShippingItemType = source.ErpShippingItemType;
target.ErpShippingItemKey = source.ErpShippingItemKey;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>10.4.36</Version>
<Version>10.21.5</Version>
Comment thread
DWDBE marked this conversation as resolved.
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<Title>Live Integration</Title>
<Description>Live Integration</Description>
Expand All @@ -19,15 +19,15 @@
<IncludeSymbols>true</IncludeSymbols>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dynamicweb.Core" Version="10.4.0" />
<PackageReference Include="Dynamicweb.CoreUI" Version="10.4.0" />
<PackageReference Include="Dynamicweb.DataIntegration" Version="10.4.0" />
<PackageReference Include="Dynamicweb.Ecommerce" Version="10.4.0" />
<PackageReference Include="Dynamicweb.Ecommerce.UI" Version="10.4.0" />
<PackageReference Include="Dynamicweb.Core" Version="10.21.5" />
<PackageReference Include="Dynamicweb.CoreUI" Version="10.21.5" />
<PackageReference Include="Dynamicweb.DataIntegration" Version="10.21.5" />
<PackageReference Include="Dynamicweb.Ecommerce" Version="10.21.5" />
<PackageReference Include="Dynamicweb.Ecommerce.UI" Version="10.21.5" />
Comment thread
DWDBE marked this conversation as resolved.
Comment thread
DWDBE marked this conversation as resolved.
Comment thread
DWDBE marked this conversation as resolved.
Comment thread
DWDBE marked this conversation as resolved.
Comment thread
DWDBE marked this conversation as resolved.
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static bool HasIdentifier(this Product product, Settings settings)
public static bool IsUnitUpdateNeeded(this Product product, string unitId)
{
if (string.IsNullOrEmpty(unitId) || product.DefaultUnitId == unitId ||
!new Stocks.UnitOfMeasureService().GetUnitOfMeasures(product.Id).Any(u => u.UnitId.Equals(unitId)))
!Services.UnitOfMeasure.GetUnitOfMeasures(product.Id).Any(u => u.UnitId.Equals(unitId)))
Comment thread
DWDBE marked this conversation as resolved.
return false;
return true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using Dynamicweb.Core;
using Dynamicweb.Security.UserManagement;
using System.Linq;

namespace Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Extensions
Comment thread
DWDBE marked this conversation as resolved.
{
public static class UserExtensions
Comment thread
DWDBE marked this conversation as resolved.
{
internal static bool IsLiveIntegrationPricesDisabled(this User user)
{
Comment thread
DWDBE marked this conversation as resolved.
if (user.IsLivePricesDisabled)
return true;

var key = $"DynamicwebLiveIntegrationIsLivePricesDisabled{user.ID}";
var cacheValue = Context.Current?.Items?[key];
if (cacheValue is not null)
{
return Converter.ToBoolean(cacheValue);
}
else
{
var groups = user.GetAncestorGroups();
bool result = groups.Any(g => g.IsLivePricesDisabled);
if (Context.Current?.Items is not null)
{
Context.Current.Items[key] = result;
}
return result;
}
}
Comment thread
DWDBE marked this conversation as resolved.
Comment thread
DWDBE marked this conversation as resolved.
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ internal static bool CanCheckPrice(Settings settings, Product product, User user
|| !settings.EnableLivePrices
|| Global.IsProductLazyLoad(settings)
|| (user == null && !settings.LiveProductInfoForAnonymousUsers)
|| (user != null && user.IsLivePricesDisabled)
|| (user != null && user.IsLiveIntegrationPricesDisabled())
|| !Connector.IsWebServiceConnectionAvailable(settings, SubmitType.Live)
|| product == null
|| string.IsNullOrEmpty(product.Id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private static Country GetCountry(User user)
}
if (country is null)
{
Comment thread
DWDBE marked this conversation as resolved.
country = new Country();
country = new Country() { Code2 = "" };
Comment thread
DWDBE marked this conversation as resolved.
Comment thread
DWDBE marked this conversation as resolved.
Comment thread
DWDBE marked this conversation as resolved.
Comment thread
DWDBE marked this conversation as resolved.
Comment thread
DWDBE marked this conversation as resolved.
Comment thread
DWDBE marked this conversation as resolved.
Comment thread
DWDBE marked this conversation as resolved.
}
return country;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,16 @@ public LiveIntegrationAddIn()
[AddInParameterOrder(210)]
public bool EnableCartCommunicationForAnonymousUsers { get; set; }

/// <summary>
/// When enabled anonymous users will receive discounts calculated by DynamicWeb instead of retrieving them from the ERP via Live Integration
/// </summary>
/// <value><c>true</c> if [disable ERP discounts calculation for anonymous users]; otherwise, <c>false</c>.</value>
[AddInParameter("Disable ERP discounts for anonymous users")]
[AddInParameterEditor(typeof(YesNoParameterEditor), "explanation=When enabled anonymous users will receive discounts calculated by DynamicWeb instead of retrieving them from the ERP via Live Integration;")]
[AddInParameterGroup("Users")]
[AddInParameterOrder(220)]
public bool DisableErpDiscountsForAnonymousUsers { get; set; }
Comment thread
DWDBE marked this conversation as resolved.
Comment thread
DWDBE marked this conversation as resolved.
Comment thread
DWDBE marked this conversation as resolved.

/// <summary>
/// Gets or sets the customer name used in integration scenarios with anonymous users.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Configuration;
using Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Extensions;
using Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Products;
using Dynamicweb.Ecommerce.Products;
using Dynamicweb.Extensibility.Notifications;
Expand Down Expand Up @@ -50,7 +51,7 @@ private static bool CanCheckPrice(Settings settings)
{
return settings.EnableLivePrices && EnabledAndActive(settings, SubmitType.Live) &&
(settings.LiveProductInfoForAnonymousUsers || Helpers.GetCurrentExtranetUser() != null) &&
(Helpers.GetCurrentExtranetUser() == null || !Helpers.GetCurrentExtranetUser().IsLivePricesDisabled) &&
(Helpers.GetCurrentExtranetUser() == null || !Helpers.GetCurrentExtranetUser().IsLiveIntegrationPricesDisabled()) &&
!Global.IsProductLazyLoad(settings);
}
}
Expand Down
Loading