Skip to content

Commit

Permalink
#2476 Discounts weren't displayed for recurring orders
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreiMaz committed Aug 4, 2017
1 parent f59ecde commit 54b1ff7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
28 changes: 26 additions & 2 deletions src/Libraries/Nop.Services/Orders/OrderProcessingService.cs
Expand Up @@ -573,6 +573,8 @@ protected virtual PlaceOrderContainter PrepareRecurringOrderDetails(ProcessPayme
//sub total
details.OrderSubTotalInclTax = details.InitialOrder.OrderSubtotalInclTax;
details.OrderSubTotalExclTax = details.InitialOrder.OrderSubtotalExclTax;
details.OrderSubTotalDiscountExclTax = details.InitialOrder.OrderSubTotalDiscountExclTax;
details.OrderSubTotalDiscountInclTax = details.InitialOrder.OrderSubTotalDiscountInclTax;

//shipping info
if (details.InitialOrder.ShippingStatus != ShippingStatus.ShippingNotRequired)
Expand Down Expand Up @@ -612,6 +614,14 @@ protected virtual PlaceOrderContainter PrepareRecurringOrderDetails(ProcessPayme
//VAT number
details.VatNumber = details.InitialOrder.VatNumber;

//discount history (the same)
foreach (var duh in details.InitialOrder.DiscountUsageHistory)
{
var d = _discountService.GetDiscountById(duh.DiscountId);
if (d != null)
details.AppliedDiscounts.Add(d.MapDiscount());
}

//order total
details.OrderDiscountAmount = details.InitialOrder.OrderDiscount;
details.OrderTotal = details.InitialOrder.OrderTotal;
Expand Down Expand Up @@ -1215,8 +1225,7 @@ public virtual PlaceOrderResult PlaceOrder(ProcessPaymentRequest processPaymentR
var details = PreparePlaceOrderDetails(processPaymentRequest);

#region Payment workflow



//process payment
ProcessPaymentResult processPaymentResult = null;
//skip payment workflow if order total equals zero
Expand Down Expand Up @@ -1817,6 +1826,21 @@ public virtual IEnumerable<string> ProcessNextRecurringPayment(RecurringPayment
string.Format(_localizationService.GetResource("Admin.StockQuantityHistory.Messages.PlaceOrder"), order.Id));
}

//discount usage history
foreach (var discount in details.AppliedDiscounts)
{
var d = _discountService.GetDiscountById(discount.Id);
if (d != null)
{
_discountService.InsertDiscountUsageHistory(new DiscountUsageHistory
{
Discount = d,
Order = order,
CreatedOnUtc = DateTime.UtcNow
});
}
}

//notifications
SendNotificationsAndSaveNotes(order);

Expand Down
Expand Up @@ -8,7 +8,6 @@
using Nop.Core.Configuration;
using Nop.Core.Data;
using Nop.Core.Infrastructure;
using Nop.Data;
using Nop.Services.Authentication;
using Nop.Services.Logging;
using Nop.Services.Tasks;
Expand Down

0 comments on commit 54b1ff7

Please sign in to comment.