Displaying the price difference once discount code applied
Hi,
I've a question with regards to discount codes and displaying the difference between the original price and the discounted price on the confirmation page just before the user pays for the products.
If I have a product in my basket and the user adds a discount code, the new total price is displayed as expected but I can't seem to find a way to display the adjusted price.
Ideally I'd have something like (simple example)
Original Price - £10
Discounted Price - £5
Total £5
I thought using Adjustment and WithoutAdjustment I could get this info but it .Adjustment always comes back as 0.
@foreach (var line in order.OrderLines.Select((ol, i) => new { OrderLine = ol, Index = i }))
{
<div class="eccommerce-checkout-body-info-label">
<p>@line.OrderLine.Name<span>x@(line.OrderLine.Quantity.ToString("0"))</span></p>
@if (Umbraco.MemberIsLoggedOn())
{
<p>@line.OrderLine.UnitPrice.Adjustment.Formatted().WithoutTax</p>
<p>@line.OrderLine.UnitPrice.WithoutAdjustments.Formatted().WithoutTax</p>
}
</div>
}
Sure, so with a "total amount discount" the discount is only present on the order.TotalPrice and so the order lines aren't going to show a level of discount as it doesn't apply at that point. The order lines would only contain info for order line discounts.
You might want to review something like our confirmation email templates as these are the most thorough places where we show price breakdowns with discounts amounts etc
The other thing I had to make sure was in the back office the discount is applied to the unit price instead of the overall subtotal (which was originally setup).
So the second reward is what now allows me to show the discount per unit price and I removed the first reward.
Displaying the price difference once discount code applied
Hi,
I've a question with regards to discount codes and displaying the difference between the original price and the discounted price on the confirmation page just before the user pays for the products.
If I have a product in my basket and the user adds a discount code, the new total price is displayed as expected but I can't seem to find a way to display the adjusted price.
Ideally I'd have something like (simple example)
Original Price - £10 Discounted Price - £5
Total £5
I thought using Adjustment and WithoutAdjustment I could get this info but it .Adjustment always comes back as 0.
While .WithAdjustment shows the correct Cost.
I also tried:
The output I get is:
This is with a 50% off the total amount discount code.
Am I using this correctly?
Thanks, O.
Hi Owain,
Sure, so with a "total amount discount" the discount is only present on the
order.TotalPrice
and so the order lines aren't going to show a level of discount as it doesn't apply at that point. The order lines would only contain info for order line discounts.You might want to review something like our confirmation email templates as these are the most thorough places where we show price breakdowns with discounts amounts etc
https://github.com/vendrhub/vendr-demo-store/blob/v2/netcore/main/src/Vendr.DemoStore.Web/App_Plugins/Vendr/templates/email/BlendidOrderConfirmationEmail.cshtml#L176
Hopefully these will give you some idea.
Matt
That's really helpful, thanks Matt. I'll check out the template and see what I can come up with.
O.
Hi Owain,
Can you let me know if you have any success?
I have a client currently looking for similar.
Thanks,
George
Ye, I did.
I did something like this -
The other thing I had to make sure was in the back office the discount is applied to the unit price instead of the overall subtotal (which was originally setup).
So the second reward is what now allows me to show the discount per unit price and I removed the first reward.
Hope that helps.
O.
Excellent, cheers Owain! Looks like it does the trick.
Great! Glad I could help :)
O.
is working on a reply...