Question

I am looking for a way to get the discount percent of an order, possibly from the order class or the invoice class, it would be amazing if

$order->getDiscountPercent();

worked, but it doesn't, any ideas on how I can pull the discount percent from either the order class or the invoice class?

Was it helpful?

Solution

As far as I know, there is no way of doing this. All discounts are calculated in $insertAnyCurrency. Therefore you have two ways, if you want this:

SalesRule

There is a $order->getCouponRuleName(). But I don't know whether this is everytime filled. With this field you can (very fuzzy) get the rules and from the rules the percentages

discount / grandtotal

You can just calculate the percentage from the discount. But this is very fuzzy too and I'm not sure, wether you need it with or without shipping and with or without tax.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top