Sort items for discounts by price. Price includes quantity
When setting up the items array, the item price is the product price * qty, or order item subtotal and so already accounts for the quantity.
This commit is contained in:
parent
452fa75038
commit
fddc63584d
|
@ -0,0 +1,4 @@
|
|||
Significance: patch
|
||||
Type: fix
|
||||
|
||||
Sort items for before applying discounts by the price property
|
|
@ -291,12 +291,10 @@ class WC_Discounts {
|
|||
* @return int
|
||||
*/
|
||||
protected function sort_by_price( $a, $b ) {
|
||||
$price_1 = $a->price * $a->quantity;
|
||||
$price_2 = $b->price * $b->quantity;
|
||||
if ( $price_1 === $price_2 ) {
|
||||
if ( $a->price === $b->price ) {
|
||||
return 0;
|
||||
}
|
||||
return ( $price_1 < $price_2 ) ? 1 : -1;
|
||||
return ( $a->price < $b->price ) ? 1 : -1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue