diff --git a/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/Dynamicweb.Ecommerce.DynamicwebLiveIntegration.csproj b/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/Dynamicweb.Ecommerce.DynamicwebLiveIntegration.csproj index 66d42dc..840a3f8 100644 --- a/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/Dynamicweb.Ecommerce.DynamicwebLiveIntegration.csproj +++ b/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/Dynamicweb.Ecommerce.DynamicwebLiveIntegration.csproj @@ -1,6 +1,6 @@  - 10.21.8 + 10.21.9 1.0.0.0 Live Integration Live Integration diff --git a/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/OrderHandler.cs b/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/OrderHandler.cs index 3a82699..5401c94 100644 --- a/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/OrderHandler.cs +++ b/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/OrderHandler.cs @@ -33,8 +33,24 @@ public static class OrderHandler /// private static readonly string OrderXmlLogFolder = "/Files/System/Log/LiveIntegration/OrderXml"; + /// + /// Prefix used by OrderLine.Id for order lines that were created as part of a multi order line + /// request but have not actually been persisted yet. Lines with this placeholder Id still need + /// to be saved before they can be used as a ParentLineId reference. + /// + private const string NewMultiOrderLineIdPrefix = "DW_NEWMULTIORDERLINEID_"; + private readonly record struct OrderResponseContext(Settings Settings, bool ErpControlsDiscountForUser); + /// + /// Determines whether an order line has not actually been persisted yet, including lines whose + /// Id was pre-assigned a temporary multi order line placeholder before saving. + /// + private static bool IsUnsavedOrderLine(OrderLine orderLine) + { + return string.IsNullOrEmpty(orderLine.Id) || orderLine.Id.StartsWith(NewMultiOrderLineIdPrefix, StringComparison.OrdinalIgnoreCase); + } + /// /// Gets the cache level for order information. /// @@ -533,7 +549,7 @@ private static void ProcessDiscountOrderLine(in OrderResponseContext ctx, Order } parentLine = parentLineWithVariant ?? parentLine; - if (parentLine != null && string.IsNullOrEmpty(parentLine.Id)) + if (parentLine != null && IsUnsavedOrderLine(parentLine)) { Services.OrderLines.Save(parentLine); orderLineIds.Add(parentLine.Id); @@ -723,7 +739,7 @@ private static void ProcessTaxOrderLine(Settings settings, Order order, XmlNode } parentLine = parentLineWithVariant ?? parentLine; - if (parentLine != null && string.IsNullOrEmpty(parentLine.Id)) + if (parentLine != null && IsUnsavedOrderLine(parentLine)) { Services.OrderLines.Save(parentLine); orderLineIds.Add(parentLine.Id);