Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

Minor changes with PlaceOrderCommandHandler.cs

support9c180e525dc4
diff --git a/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/PlaceOrderCommandHandler.cs b/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/PlaceOrderCommandHandler.cs
index 05d93b316..25ab73008 100644
--- a/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/PlaceOrderCommandHandler.cs
+++ b/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/PlaceOrderCommandHandler.cs
@@ -38,7 +38,6 @@ namespace Grand.Business.Checkout.Commands.Handlers.Orders
public class PlaceOrderCommandHandler : IRequestHandler<PlaceOrderCommand, PlaceOrderResult>
{
private readonly IOrderService _orderService;
- private readonly ITranslationService _translationService;
private readonly ILanguageService _languageService;
private readonly IProductService _productService;
private readonly IInventoryManageService _inventoryManageService;
@@ -47,7 +46,6 @@ namespace Grand.Business.Checkout.Commands.Handlers.Orders
private readonly ILogger _logger;
private readonly IOrderCalculationService _orderTotalCalculationService;
private readonly IPricingService _pricingService;
- private readonly IPriceFormatter _priceFormatter;
private readonly IProductAttributeFormatter _productAttributeFormatter;
private readonly IGiftVoucherService _giftVoucherService;
private readonly ICheckoutAttributeFormatter _checkoutAttributeFormatter;
@@ -75,7 +73,6 @@ namespace Grand.Business.Checkout.Commands.Handlers.Orders
public PlaceOrderCommandHandler(
IOrderService orderService,
- ITranslationService translationService,
ILanguageService languageService,
IProductService productService,
IInventoryManageService inventoryManageService,
@@ -84,7 +81,6 @@ namespace Grand.Business.Checkout.Commands.Handlers.Orders
ILogger logger,
IOrderCalculationService orderTotalCalculationService,
IPricingService priceCalculationService,
- IPriceFormatter priceFormatter,
IProductAttributeFormatter productAttributeFormatter,
IGiftVoucherService giftVoucherService,
ICheckoutAttributeFormatter checkoutAttributeFormatter,
@@ -111,7 +107,6 @@ namespace Grand.Business.Checkout.Commands.Handlers.Orders
TaxSettings taxSettings)
{
_orderService = orderService;
- _translationService = translationService;
_languageService = languageService;
_productService = productService;
_inventoryManageService = inventoryManageService;
@@ -120,7 +115,6 @@ namespace Grand.Business.Checkout.Commands.Handlers.Orders
_logger = logger;
_orderTotalCalculationService = orderTotalCalculationService;
_pricingService = priceCalculationService;
- _priceFormatter = priceFormatter;
_productAttributeFormatter = productAttributeFormatter;
_giftVoucherService = giftVoucherService;
_checkoutAttributeFormatter = checkoutAttributeFormatter;
@@ -206,7 +200,7 @@ namespace Grand.Business.Checkout.Commands.Handlers.Orders
{
await _paymentTransactionService.SetError(processPayment.paymentTransaction.Id, processPayment.paymentResult.Errors.ToList());
foreach (var paymentError in processPayment.paymentResult.Errors)
- result.AddError(string.Format(_translationService.GetResource("Checkout.PaymentError"), paymentError));
+ result.AddError(paymentError);
}
}
catch (Exception exc)
@@ -616,15 +610,8 @@ namespace Grand.Business.Checkout.Commands.Handlers.Orders
{
details.AppliedDiscounts.Add(disc);
}
-
- //attributes
var attributeDescription = await _productAttributeFormatter.FormatAttributes(product, sc.Attributes, details.Customer);
-
- if (string.IsNullOrEmpty(attributeDescription) && sc.ShoppingCartTypeId == ShoppingCartType.Auctions)
- attributeDescription = _translationService.GetResource("ShoppingCart.AuctionWonOn") + " " + product.AvailableEndDateTimeUtc;
-
var itemWeight = await GetShoppingCartItemWeight(sc);
-
var warehouseId = !string.IsNullOrEmpty(sc.WarehouseId) ? sc.WarehouseId : _workContext.CurrentStore.DefaultWarehouseId;
if (!product.UseMultipleWarehouses && string.IsNullOrEmpty(warehouseId))
{
@@ -672,6 +659,22 @@ namespace Grand.Business.Checkout.Commands.Handlers.Orders
cId = sc.cId
};
+ var reservationInfo = ReservationInfo(sc, product);
+
+ if (string.IsNullOrEmpty(reservationInfo)) return orderItem;
+ if (!string.IsNullOrEmpty(orderItem.AttributeDescription))
+ {
+ orderItem.AttributeDescription += "<br>" + reservationInfo;
+ }
+ else
+ {
+ orderItem.AttributeDescription = reservationInfo;
+ }
+ return orderItem;
+ }
+
+ private static string ReservationInfo(ShoppingCartItem sc, Product product)
+ {
var reservationInfo = "";
if (product.ProductTypeId == ProductType.Reservation)
{
@@ -683,26 +686,19 @@ namespace Grand.Business.Checkout.Commands.Handlers.Orders
{
reservationInfo = sc.RentalStartDateUtc + " - " + sc.RentalEndDateUtc;
}
+
if (!string.IsNullOrEmpty(sc.Parameter))
{
- reservationInfo += "<br>" + string.Format(_translationService.GetResource("ShoppingCart.Reservation.Option"), sc.Parameter);
+ reservationInfo += "<br>" + sc.Parameter;
}
+
if (!string.IsNullOrEmpty(sc.Duration))
{
- reservationInfo += "<br>" + _translationService.GetResource("Products.Duration") + ": " + sc.Duration;
+ reservationInfo += "<br>" + sc.Duration;
}
}
- if (string.IsNullOrEmpty(reservationInfo)) return orderItem;
- if (!string.IsNullOrEmpty(orderItem.AttributeDescription))
- {
- orderItem.AttributeDescription += "<br>" + reservationInfo;
- }
- else
- {
- orderItem.AttributeDescription = reservationInfo;
- }
- return orderItem;
+ return reservationInfo;
}
protected virtual async Task GenerateGiftVoucher(PlaceOrderContainer details, ShoppingCartItem sc, Order order, OrderItem orderItem, Product product)