Skip to content

Commit

Permalink
VCST-1698: prepare shipment middleware (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
ksavosteev authored Sep 12, 2024
1 parent 1dbbb57 commit 8cac4c1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/VirtoCommerce.XCart.Core/CartAggregate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,15 @@ public virtual async Task<CartAggregate> AddShipmentAsync(Shipment shipment, IEn
shipment.Price = shippingMethod.Rate;
shipment.DiscountAmount = shippingMethod.DiscountAmount;
}

// pass shipment to the middleware pipeline
var shipmentContext = new ShipmentContextCartMap
{
CartAggregate = this,
Shipment = shipment,
};
await _pipeline.Execute(shipmentContext);

return this;
}

Expand Down
11 changes: 11 additions & 0 deletions src/VirtoCommerce.XCart.Core/Models/ShipmentContextCartMap.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using VirtoCommerce.CartModule.Core.Model;

namespace VirtoCommerce.XCart.Core.Models
{
public class ShipmentContextCartMap
{
public CartAggregate CartAggregate { get; set; }

public Shipment Shipment { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ public static IServiceCollection AddXCart(this IServiceCollection services, IGra
builder.AddMiddleware(typeof(MapPromoEvalContextMiddleware));
});

services.AddPipeline<ShipmentContextCartMap>();

return services;
}
}
Expand Down

0 comments on commit 8cac4c1

Please sign in to comment.