Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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>
bool DisableErpDiscountsForAnonymousUsers { get; set; }
}
}
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; }

#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>
<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" />
<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)))
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
{
internal static class UserExtensions
{
internal static bool IsLiveIntegrationPricesDisabled(this User user)
{
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;
}
}
}
}
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 = "" };
}
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.

/// <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