Skip to content

Commit

Permalink
VCST-2173: Empty totals if shipment is requested (#572)
Browse files Browse the repository at this point in the history
fix: Empty totals if shipment is requested
  • Loading branch information
OlegoO committed Nov 1, 2024
1 parent b69a805 commit bc35113
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ namespace VirtoCommerce.XPurchase
[Flags]
public enum CartAggregateResponseGroup
{
None = 0,
Default = 0,
WithPayments = 1,
WithLineItems = 1 << 1,
WithShipments = 1 << 2,
Validate = 1 << 3,
WithDynamicProperties = 1 << 4,
Full = WithPayments | WithLineItems | WithShipments | Validate | WithDynamicProperties
WithDynamicProperties = 1 << 3,
RecalculateTotals = 1 << 4,
Full = Default | WithPayments | WithLineItems | WithShipments | WithDynamicProperties | RecalculateTotals
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,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 = CartAggregateResponseGroup.Full;

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

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

return result.ToString();
Expand Down

0 comments on commit bc35113

Please sign in to comment.