diff --git a/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Controllers/CustomOrderController.cs b/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Controllers/CustomOrderController.cs index c92de77..b253e2a 100644 --- a/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Controllers/CustomOrderController.cs +++ b/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Controllers/CustomOrderController.cs @@ -587,7 +587,18 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers throw new Exception($"{errorText}"); } - var orderItem = await CreateOrderItem(product, order, orderProductItem, isMeasurable, unitPricesIncludeDiscounts, customer, store); + if(orderProductItem.Price != product.Price) + { + //manual price change + unitPricesIncludeDiscounts = false; + } + else + { + unitPricesIncludeDiscounts = true; + } + + + var orderItem = await CreateOrderItem(product, order, orderProductItem, isMeasurable, unitPricesIncludeDiscounts, customer, store); await _orderService.InsertOrderItemAsync(orderItem); await _productService.AdjustInventoryAsync(product, -orderItem.Quantity, orderItem.AttributesXml, string.Format(await _localizationService.GetResourceAsync("Admin.StockQuantityHistory.Messages.PlaceOrder"), order.Id)); @@ -622,13 +633,23 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers store ??= await _storeContext.GetCurrentStoreAsync(); customer ??= await _workContext.GetCurrentCustomerAsync(); - - var priceCalculation = await _priceCalculationService.GetFinalPriceAsync(product, customer, store, includeDiscounts: unitPricesIncludeDiscounts); - var unitPriceInclTaxValue = priceCalculation.finalPrice; - // Calculate tax - //var (unitPriceInclTaxValue, _) = await _taxService.GetProductPriceAsync(product, unitPrice, true, customer); - var (unitPriceExclTaxValue, _) = await _taxService.GetProductPriceAsync(product, unitPriceInclTaxValue, false, customer); + decimal unitPriceInclTaxValue = 0; + + if (unitPricesIncludeDiscounts) + { + var priceCalculation = await _priceCalculationService.GetFinalPriceAsync(product, customer, store, includeDiscounts: unitPricesIncludeDiscounts); + unitPriceInclTaxValue = priceCalculation.finalPrice; + } + else + { + unitPriceInclTaxValue = orderProductItem.Price; + } + + + // Calculate tax + //var (unitPriceInclTaxValue, _) = await _taxService.GetProductPriceAsync(product, unitPrice, true, customer); + var (unitPriceExclTaxValue, _) = await _taxService.GetProductPriceAsync(product, unitPriceInclTaxValue, false, customer); return new OrderItem {