Skip to content
Draft
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,8 +23,8 @@
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dynamicweb" Version="10.4.0" />
<PackageReference Include="Dynamicweb.Core" Version="10.4.0" />
<PackageReference Include="Dynamicweb" Version="10.19.9" />
<PackageReference Include="Dynamicweb.Core" Version="10.19.9" />
<PackageReference Include="Dynamicweb.DataIntegration" Version="10.4.0" />
<PackageReference Include="Dynamicweb.Ecommerce" Version="10.4.0" />
</ItemGroup>
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
@@ -1,4 +1,7 @@
namespace Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Configuration
using Dynamicweb.Extensibility.AddIns;
using Dynamicweb.Extensibility.Editors;

namespace Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Configuration
{
/// <summary>
/// Interface to define settings for the Live Integration.
Expand Down Expand Up @@ -327,5 +330,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; }
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using Dynamicweb.Core;
using Dynamicweb.Core.Helpers;
using Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Cache;
using Dynamicweb.Extensibility.AddIns;
using Dynamicweb.Extensibility.Editors;
using Dynamicweb.Security.UserManagement;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -329,6 +331,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 @@ -456,6 +464,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.31</Version>
<Version>10.20.0</Version>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<Title>Live Integration</Title>
<Description>Live Integration</Description>
Expand All @@ -23,7 +23,7 @@
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dynamicweb.Core" Version="10.4.0" />
<PackageReference Include="Dynamicweb.Core" Version="10.19.9" />
<PackageReference Include="Dynamicweb.CoreUI" Version="10.4.0" />
<PackageReference Include="Dynamicweb.DataIntegration" Version="10.4.0" />
<PackageReference Include="Dynamicweb.Ecommerce" Version="10.4.0" />
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
{
public 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);

Check failure on line 23 in src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/Extensions/UserExtensions.cs

View workflow job for this annotation

GitHub Actions / call-workflow / Build

'UserGroup' does not contain a definition for 'IsLivePricesDisabled' and no accessible extension method 'IsLivePricesDisabled' accepting a first argument of type 'UserGroup' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 23 in src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/Extensions/UserExtensions.cs

View workflow job for this annotation

GitHub Actions / call-workflow / Build

'UserGroup' does not contain a definition for 'IsLivePricesDisabled' and no accessible extension method 'IsLivePricesDisabled' accepting a first argument of type 'UserGroup' could be found (are you missing a using directive or an assembly reference?)
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 @@ -29,7 +29,7 @@
[AddInIgnore(false)]
[AddInUseParameterGrouping(true)]
[AddInUseParameterOrdering(true)]
public class LiveIntegrationAddIn : BaseLiveIntegrationAddIn, IDropDownOptions, ISettings

Check warning on line 32 in src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/LiveIntegrationAddIn.cs

View workflow job for this annotation

GitHub Actions / call-workflow / Build

'IDropDownOptions' is obsolete: 'Use IParameterOptions instead.'

Check warning on line 32 in src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/LiveIntegrationAddIn.cs

View workflow job for this annotation

GitHub Actions / call-workflow / Build

'IDropDownOptions' is obsolete: 'Use IParameterOptions instead.'
{
/// <summary>
/// Initializes a new instance of the <see cref="LiveIntegrationAddIn"/> class.
Expand Down Expand Up @@ -465,6 +465,16 @@
[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; }

/// <summary>
/// Gets or sets the customer name used in integration scenarios with anonymous users.
/// </summary>
Expand Down Expand Up @@ -494,7 +504,7 @@
/// </summary>
/// <value>The notification email.</value>
[AddInParameter("Notification recipient groups")]
[AddInParameterEditor(typeof(UserGroupParameterEditor), "Multiple=true;")]
[AddInParameterEditor(typeof(UserGroupParameterEditor), "Multiple=true;")]
[AddInParameterGroup("Notifications")]
[AddInParameterOrder(235)]
public string RecipientGroups { get; set; }
Expand Down Expand Up @@ -807,7 +817,7 @@
{
AutoPingInterval = Constants.MinPingInterval;
}
if(ConnectionTimeout < Constants.DefaultConnectionTimeout)
if (ConnectionTimeout < Constants.DefaultConnectionTimeout)
{
ConnectionTimeout = Constants.DefaultConnectionTimeout;
}
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 EnabledAndActive(settings, SubmitType.Live) && settings.EnableLivePrices &&
(settings.LiveProductInfoForAnonymousUsers || Helpers.GetCurrentExtranetUser() != null) &&
(Helpers.GetCurrentExtranetUser() == null || !Helpers.GetCurrentExtranetUser().IsLivePricesDisabled) &&
(Helpers.GetCurrentExtranetUser() == null || !Helpers.GetCurrentExtranetUser().IsLiveIntegrationPricesDisabled()) &&
!Global.IsProductLazyLoad(settings);
}
}
Expand Down
Loading
Loading