Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VCST-1698: prepare shipment middleware #9

Merged
merged 2 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading