order price fix

This commit is contained in:
Adam 2025-11-25 09:48:10 +01:00
parent 22307c2318
commit 8e3829670b
1 changed files with 28 additions and 7 deletions

View File

@ -587,6 +587,17 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
throw new Exception($"{errorText}"); throw new Exception($"{errorText}");
} }
if(orderProductItem.Price != product.Price)
{
//manual price change
unitPricesIncludeDiscounts = false;
}
else
{
unitPricesIncludeDiscounts = true;
}
var orderItem = await CreateOrderItem(product, order, orderProductItem, isMeasurable, unitPricesIncludeDiscounts, customer, store); var orderItem = await CreateOrderItem(product, order, orderProductItem, isMeasurable, unitPricesIncludeDiscounts, customer, store);
await _orderService.InsertOrderItemAsync(orderItem); await _orderService.InsertOrderItemAsync(orderItem);
@ -623,8 +634,18 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
store ??= await _storeContext.GetCurrentStoreAsync(); store ??= await _storeContext.GetCurrentStoreAsync();
customer ??= await _workContext.GetCurrentCustomerAsync(); customer ??= await _workContext.GetCurrentCustomerAsync();
decimal unitPriceInclTaxValue = 0;
if (unitPricesIncludeDiscounts)
{
var priceCalculation = await _priceCalculationService.GetFinalPriceAsync(product, customer, store, includeDiscounts: unitPricesIncludeDiscounts); var priceCalculation = await _priceCalculationService.GetFinalPriceAsync(product, customer, store, includeDiscounts: unitPricesIncludeDiscounts);
var unitPriceInclTaxValue = priceCalculation.finalPrice; unitPriceInclTaxValue = priceCalculation.finalPrice;
}
else
{
unitPriceInclTaxValue = orderProductItem.Price;
}
// Calculate tax // Calculate tax
//var (unitPriceInclTaxValue, _) = await _taxService.GetProductPriceAsync(product, unitPrice, true, customer); //var (unitPriceInclTaxValue, _) = await _taxService.GetProductPriceAsync(product, unitPrice, true, customer);