Skip to content

Commit

Permalink
Merge pull request WalletWasabi#12456 from Szpoti/fixShippignCost
Browse files Browse the repository at this point in the history
[BaB] Fix shipping cost not showing
  • Loading branch information
molnard authored Feb 16, 2024
2 parents a50e243 + 862336b commit 848df26
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
21 changes: 19 additions & 2 deletions WalletWasabi/BuyAnything/BuyAnythingManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ when serverEvent.HasFlag(ServerEvent.MakeOffer):

await SendSystemChatLinesAsync(track,
ConvertOfferDetailToMessages(order),
new OfferCarrier(order.LineItems.Select(x => new OfferItem(x.Quantity, x.Label, x.UnitPrice, x.TotalPrice)), order.ShippingCosts),
new OfferCarrier(order.LineItems.Select(x => new OfferItem(x.Quantity, x.Label, x.UnitPrice, x.TotalPrice)), GetShippingCostFromOrder(order)),
order.UpdatedAt, ConversationStatus.OfferReceived, cancel).ConfigureAwait(false);
break;

Expand Down Expand Up @@ -571,6 +571,8 @@ private string[] GetLinksByLine(string attachmentsLinks) =>
private static string ConvertOfferDetailToMessages(Order order)
{
StringBuilder sb = new();

var shippingCost = GetShippingCostFromOrder(order);
sb.AppendLine("Our offer includes:");
foreach (var lineItem in order.LineItems)
{
Expand All @@ -585,10 +587,25 @@ private static string ConvertOfferDetailToMessages(Order order)
}

sb.AppendLine($"\nFor a total price of ${order.AmountTotal}.");
sb.AppendLine($"(Including ${order.ShippingCosts.TotalPrice} shipping cost.)");
sb.AppendLine($"(Including ${shippingCost.TotalPrice} shipping cost.)");
return sb.ToString();
}

private static ShippingCosts GetShippingCostFromOrder(Order order)
{
if (order.ShippingCosts.TotalPrice != "0")
{
return order.ShippingCosts;
}

float sum = 0;
foreach (var delivery in order.Deliveries)
{
sum += float.Parse(delivery.ShippingCosts.TotalPrice);
}
return new ShippingCosts(sum.ToString());
}

public async Task EnsureConversationsAreLoadedAsync(CancellationToken cancellationToken)
{
if (!IsConversationsLoaded)
Expand Down
6 changes: 3 additions & 3 deletions WalletWasabi/WebClients/ShopWare/Models/Order.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ public record Deliveries
(
string OrderId,
string[] TrackingCodes,
StateMachineState StateMachineState

);
StateMachineState StateMachineState,
ShippingCosts ShippingCosts
);
public record OrderCustomFields
(
string Concierge_Request_Status_State,
Expand Down

0 comments on commit 848df26

Please sign in to comment.