Getting discount for productvariant

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
12 năm cách đây
Hello,

I have developed a control that will display the amount that is being saved on any particular product i.e. Save £5 or Save 12%.

My code is pretty simple, I get a handle on the variant (if there is only one of them). I can easily get at the amount the discount is saving by using:

PriceHelper.GetDiscountAmount(productVariant)

But what I want to get a handle on is the discount that nop is applying to the variant. It could of course be a discount set at the category level or variant level. I see there is a method DiscountService.GetPreferredDiscount but I'm not sure how i can use it with a variant?

Any ideas please?

Thanks
Al
12 năm cách đây
If the order hasn't been made, you may refer to nopCommerce2.2\Libraries\Nop.Services\Orders\OrderTotalCalculationService.cs
GetOrderSubtotalDiscount method.

Otherwise, you may check [DiscountUsageHistory] table to find the discount(s) applied to an order.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.