Skip to content

Commit

Permalink
VCST-2173: Empty totals if shipment is requested (#15)
Browse files Browse the repository at this point in the history
fix: Empty totals if shipment is requested
  • Loading branch information
OlegoO authored Nov 1, 2024
1 parent 41e4094 commit e6f1f98
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace VirtoCommerce.XCart.Core.Models
{
[Obsolete("Use CartResponseGroup", DiagnosticId = "VC0009", UrlFormat = "https://docs.virtocommerce.org/platform/user-guide/versions/virto3-products-versions/")]
[Flags]
public enum CartAggregateResponseGroup
{
Expand Down
29 changes: 9 additions & 20 deletions src/VirtoCommerce.XCart.Data/Services/CartResponseGroupParser.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using VirtoCommerce.XCart.Core.Models;
using VirtoCommerce.CartModule.Core.Model;
using VirtoCommerce.XCart.Core.Services;

namespace VirtoCommerce.XCart.Data.Services
Expand All @@ -9,26 +9,15 @@ public class CartResponseGroupParser : ICartResponseGroupParser
{
public virtual string GetResponseGroup(IList<string> includeFields)
{
var result = CartAggregateResponseGroup.None;
if (includeFields.Any(x => x.Contains("shipments")))
{
result |= CartAggregateResponseGroup.WithShipments;
}
if (includeFields.Any(x => x.Contains("payments")))
{
result |= CartAggregateResponseGroup.WithPayments;
}
if (includeFields.Any(x => x.Contains("items")))
{
result |= CartAggregateResponseGroup.WithLineItems;
}
if (includeFields.Any(x => x.Contains("dynamicProperties")))
{
result |= CartAggregateResponseGroup.WithDynamicProperties;
}
if (includeFields.Any(x => x.Contains("validationErrors")))
var result = CartResponseGroup.Full;

// Disable recalculation of totals, XAPI will do it on its own
result &= ~CartResponseGroup.RecalculateTotals;

if (!includeFields.Any(x => x.Contains("dynamicProperties")))
{
result |= CartAggregateResponseGroup.Validate;
// Disable load of dynamic properties if not requested
result &= ~CartResponseGroup.WithDynamicProperties;
}

return result.ToString();
Expand Down

0 comments on commit e6f1f98

Please sign in to comment.