Skip to content

Commit

Permalink
Merge branch 'dev' into feat/VCST-1630
Browse files Browse the repository at this point in the history
  • Loading branch information
Lenajava1 authored Aug 13, 2024
2 parents d3a2cea + 94a89f9 commit 264a3fc
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project>
<!-- These properties will be shared for all projects -->
<PropertyGroup>
<VersionPrefix>3.802.0</VersionPrefix>
<VersionPrefix>3.804.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
<VersionSuffix Condition=" '$(VersionSuffix)' != '' AND '$(BuildNumber)' != '' ">$(VersionSuffix)-$(BuildNumber)</VersionSuffix>
</PropertyGroup>
Expand Down
32 changes: 23 additions & 9 deletions src/VirtoCommerce.XCart.Core/CartAggregate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -959,32 +959,46 @@ protected virtual bool CheckPricePolicy(TierPrice tierPrice)
return tierPrice.Price.Amount > 0;
}

protected virtual async Task<CartAggregate> InnerAddLineItemAsync(LineItem lineItem, CartProduct product = null, IList<DynamicPropertyValue> dynamicProperties = null)
protected virtual async Task<CartAggregate> InnerAddLineItemAsync(LineItem newLineItem, CartProduct product = null, IList<DynamicPropertyValue> dynamicProperties = null)
{
var existingLineItem = LineItems.FirstOrDefault(li => li.ProductId == lineItem.ProductId);
var existingLineItem = FindExistingLineItemBeforeAdd(newLineItem.ProductId, product, dynamicProperties);

if (existingLineItem != null)
{
await InnerChangeItemQuantityAsync(existingLineItem, existingLineItem.Quantity + Math.Max(1, lineItem.Quantity), product);
await InnerChangeItemQuantityAsync(existingLineItem, existingLineItem.Quantity + Math.Max(1, newLineItem.Quantity), product);

existingLineItem.FulfillmentCenterId = lineItem.FulfillmentCenterId;
existingLineItem.FulfillmentCenterName = lineItem.FulfillmentCenterName;
existingLineItem.FulfillmentCenterId = newLineItem.FulfillmentCenterId;
existingLineItem.FulfillmentCenterName = newLineItem.FulfillmentCenterName;

lineItem = existingLineItem;
newLineItem = existingLineItem;
}
else
{
lineItem.Id = null;
Cart.Items.Add(lineItem);
newLineItem.Id = null;
Cart.Items.Add(newLineItem);
}

if (dynamicProperties != null)
{
await UpdateCartItemDynamicProperties(lineItem, dynamicProperties);
await UpdateCartItemDynamicProperties(newLineItem, dynamicProperties);
}

return this;
}

/// <summary>
/// Responsible for finding an existing line item before adding a new one.
/// If method returns line item, it means that the new line item should be merged with the existing one.
/// </summary>
/// <param name="newProductId">new product id</param>
/// <param name="newProduct">new product object</param>
/// <param name="newDynamicProperties">new dynamuc properties that should be added/updated in cart line item</param>
/// <returns></returns>
protected virtual LineItem FindExistingLineItemBeforeAdd(string newProductId, CartProduct newProduct, IList<DynamicPropertyValue> newDynamicProperties)
{
return LineItems.FirstOrDefault(x => x.ProductId == newProductId);
}

protected virtual void EnsureCartExists()
{
if (Cart == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<ItemGroup>
<PackageReference Include="FluentValidation" Version="11.8.1" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
<PackageReference Include="VirtoCommerce.Xapi.Core" Version="3.800.0" />
<PackageReference Include="VirtoCommerce.Xapi.Core" Version="3.802.0" />
<PackageReference Include="VirtoCommerce.XCatalog.Core" Version="3.800.0" />
<PackageReference Include="VirtoCommerce.CartModule.Core" Version="3.810.0" />
<PackageReference Include="VirtoCommerce.PaymentModule.Core" Version="3.800.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ protected override Task AfterMediatorSend(IResolveFieldContext<object> context,

protected override async Task Authorize(IResolveFieldContext context, object resource, IAuthorizationRequirement requirement)
{
await _userManagerCore.CheckUserState(context.GetCurrentUserId(), allowAnonymous: true);
await _userManagerCore.CheckCurrentUserState(context, allowAnonymous: true);

await base.Authorize(context, resource, requirement);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ protected override Task AfterMediatorSend(IResolveFieldContext<object> context,

protected override async Task Authorize(IResolveFieldContext context, object resource, IAuthorizationRequirement requirement)
{
await _userManagerCore.CheckUserState(context.GetCurrentUserId(), allowAnonymous: true);
await _userManagerCore.CheckCurrentUserState(context, allowAnonymous: true);

await base.Authorize(context, resource, requirement);
}
Expand Down
2 changes: 1 addition & 1 deletion src/VirtoCommerce.XCart.Data/Schemas/PurchaseSchema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1683,7 +1683,7 @@ private static void InitializeWishlistUserContextScope(WishlistUserContext conte

private async Task AuthorizeAsync(IResolveFieldContext context, object resource)
{
await _userManagerCore.CheckUserState(context.GetCurrentUserId(), allowAnonymous: true);
await _userManagerCore.CheckCurrentUserState(context, allowAnonymous: true);
var authorizationResult = await _authorizationService.AuthorizeAsync(context.GetCurrentPrincipal(), resource, new CanAccessCartAuthorizationRequirement());

if (!authorizationResult.Succeeded)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
<PackageReference Include="VirtoCommerce.Platform.Security" Version="3.841.0" />
<PackageReference Include="VirtoCommerce.Platform.Security" Version="3.848.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\VirtoCommerce.XCart.Core\VirtoCommerce.XCart.Core.csproj" />
Expand Down
8 changes: 4 additions & 4 deletions src/VirtoCommerce.XCart.Web/module.manifest
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<module>
<id>VirtoCommerce.XCart</id>
<version>3.802.0</version>
<version>3.804.0</version>
<version-tag></version-tag>

<platformVersion>3.841.0</platformVersion>
<platformVersion>3.848.0</platformVersion>
<dependencies>
<dependency id="VirtoCommerce.Xapi" version="3.800.0" />
<dependency id="VirtoCommerce.Xapi" version="3.802.0" />
<dependency id="VirtoCommerce.XCatalog" version="3.800.0" />
<dependency id="VirtoCommerce.Cart" version="3.810.0" />
<dependency id="VirtoCommerce.Inventory" version="3.800.0" />
Expand Down Expand Up @@ -39,7 +39,7 @@
<groups>
<group>commerce</group>
</groups>

<projectUrl>https://github.com/VirtoCommerce/vc-module-x-cart</projectUrl>
<iconUrl>Modules/$(VirtoCommerce.XCart)/Content/logo.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
Expand Down

0 comments on commit 264a3fc

Please sign in to comment.